B4J Question Is there a way to pass array parameters to Jrdc config file?

Enrico Fuoti

Active Member
Licensed User
Longtime User
Hi all,
I would need to execute a query tha takes an array as a parameter for an "in (array)" clause ..
Is there any way to do that?
 

Enrico Fuoti

Active Member
Licensed User
Longtime User
I understand "in" clause is not supported in JRDC, but i finally ended up using a little trick to solve the problem.
I passed the array as a single string parameter where each item is concatenated and separated by a key code. in my case I used the "#" key.
example:
B4X:
'*********************
Sub callServices
'*********************
   Dim cmd As DBCommand
   Dim li_nservices, li_i As Int
   Dim ls_service As String  'single string hosting array
   li_nservices = gs_services.Size

   ' Create single string from list array ------------------
   ls_service ="#"
   For li_i = 0 To li_nservices - 1
     ls_service = ls_service & gs_services.Get(li_i) & "#"
   Next
   cmd.Initialize  
   ' select query   --------
     cmd.Name = "qservices"  
     cmd.Parameters = Array As Object(ls_service)
     reqManager.ExecuteQuery(cmd, 0, "qservices")
End Sub


in jrdc config file your query would be:
sql.qservices = select field1, field2, field3 from table where (locate(concat('#',service,'#'),?))

I hope this may help someone else facing the same issue.
 
Upvote 0
Top