Android Question Variable table name through jRDC

Status
Not open for further replies.

yiankos1

Active Member
Licensed User
I have a mySQL server that creates daily a new table according to daily date. So i use this code:

Android code:
B4X:
    cmd.Initialize
    cmd.Name = "selectAll"
'Parameters for table name
    cmd.Parameters = Array As Object("01_01_2017","01_01_2017")
    reqManager.ExecuteQuery(cmd,0,"selectAll")

config file
B4X:
sql.selectAll=SELECT * FROM daily.? WHERE daily.?.agms=265475

I get error setting "?" for variable table name
B4X:
<pre>    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &apos;&apos;01_01_2017&apos; WHERE daily.&apos;01_01_2017&apos;.agms=265475&apos; at line 1</pre></p>

My question is how can i set a mySQL command for a variable table name.
Thank you for your time.
 

azzam223

Active Member
Licensed User
Did add items to array or not ?

If didn't then you must add it maybe the error is because you did not add items as Oliver say

I assume that you added the items to array if not then you must add it
 
Upvote 0

marconotsopolo

Member
Licensed User
The issue is not which index location of the parameter (first or last) the table name is located, the issue is that the params array is not repopulated after is reDIMmed.

Also
B4X:
Dim params(cmd.Parameters.Length - 2)
should still just be
B4X:
Dim params(cmd.Parameters.Length - 1)
. The new params array is only one item shorter (the table name) than the original params array. The issue now is that this new params array is empty and has not been populated. The crucial missing steps are to copy the proper, non-table, elements from the passed on Parameters to the new, one less element, params array. Without that step, an empty array is used in the ExecQuery2 method and produces the failure/error message.

Hi

I am sorry to post a question so late on from this original post, but how do you populate the new array prior to the re-dim. Would you have any code example so that I may better understand this process, as this fits my current problem exactly.

Thanks and apologies again..
Mark
 
Upvote 0
Status
Not open for further replies.
Top