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

yfleury

Active Member
Licensed User
Longtime User
I need to spend more argument for the same column. Is it possible to do it like this

B4X:
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
B4X:
sql.select_mytable= select * from table where item1 = ?  ? order by item3

Can I do this?
 

OliverA

Expert
Licensed User
Longtime 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:
B4X:
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
B4X:
Dim cmd as DBCommand = CreateCommand($"select_mytable${myListItem2.size}"$, item2myListItem2)
Note: No error checking (that myListItem2 contains more elements than statements created, etc.)
 
Upvote 0
Top