Android Question Strange ExecNonQuery2

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have this code
B4X:
Main.SQLMem.ExecNonQuery2("insert into MEM_CSH_BNK_IN_OT values(?,?,?,?,?,?,?)", Array As Object(RowId,Main.PUB_ID_PYMNT_TYP,IdAcN,txtCB.Text,Amnt,DscP))

It runs OK in B4A 10 without any errors even though the array size is different with the number of parameters.

The MEM_CSH_BNK_IN_OT is a sqlite in memory table.
 

drgottjr

Expert
Licensed User
Longtime User
the problem is that there is no error message. there should be. the bound parameters are a miscount.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Try taking away a ? from the SQL statement or you are meant to add one more argument to the array that you forgot maybe
The OP is telling you that there is no error. That is what is strange. She should be getting an error. Maybe the OP needs to make his post clearer and post some more code and maybe his table structure, etc. He is not giving enough information. Please read his first post again.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the miscount is supposed to have thrown an error. it didn't. that's why he says it strange. he knows there is a difference between the number of placeholders and the actual number of parameters passed. sqlite's documentation says it throws an error, but we don't know exactly how our sql.jar handles things.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Missing parameter values are set to null. On the other hand a miscount of ? will throw an error. I have to guess it's an error catch somewhere.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
in the interest of full disclosure, these queries behave the same way on b4j and b4a:

when the parameters passed are fewer than the number of placeholders, no error. (*see below)
when the parameters passed are greater in number than the number of placeholder, crash.

*in the case of fewer parameters, and where the missing parameters was of type int, a 0 was conveniently filled in. so, in my tests, the missing parm was not set to null.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
In my opinion, if number of place holders are not the same with the number of parameters, error should be raised.
 
Upvote 0
Top