B4J Question Can I send a part of sql string from smartphone to jrdc2 server

Discussion in 'B4J Questions' started by yfleury, Nov 10, 2019 at 4:36 PM.

  1. yfleury

    yfleury Active Member Licensed User

    I need to spend more argument for the same column. Is it possible to do it like this

    Code:
    Dim item1 as string="ok"
    Dim ManyItem as string=" and ("
    For x=0 to myListItem2.size - 1
     
    if x=0 then
      ManyItem = ManyItem 
    " item2=" & item2myListItem2.get(x)
     
    else
       ManyItem = ManyItem 
    " or item2=" & item2myListItem2.get(x)
     
    end if
    next
    ManyItem = ManyItem & 
    ")"
    Dim cmd As DBCommand = CreateCommand("select_mytable"Array(item1)


    On jrdc2 server
    Code:
    sql.select_mytable= select * from table where item1 = ?  ? order by item3
    Can I do this?
     
  2. OliverA

    OliverA Expert Licensed User

    Not without modifying the source of jRDC2 server to handle dynamic SQL statements. If the number of items in myListItem2 are limited (let's say up to 10), then another approach, that does not involve dynamically creating SQL queries, may be to add the following to your config properties file:
    Code:
    sql.select_mytable1= select * from table where item1 = ? order by item3
    sql.select_mytable2= select * from table where item1 in (?, ?) order by item3
    sql.select_mytable3= select * from table where item1 in (?, ?, ?) order by item3
    '... and so on
    and on the client side you could do
    Code:
    Dim cmd as DBCommand = CreateCommand($"select_mytable${myListItem2.size}"$, item2myListItem2)
    Note: No error checking (that myListItem2 contains more elements than statements created, etc.)
     
    Erel and José J. Aguilar like this.
  3. yfleury

    yfleury Active Member Licensed User

    item1 may have 1 to more of 25 items for the query
     
  4. OliverA

    OliverA Expert Licensed User

    inakigarm likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice