Hello!
I'm using parameterised queries since I've started writing with B4X.
These days I'm writing an expansion to one of my projects and I have been fallen to the following case:
SQLQuery = "SELECT * FROM sometable "
SQLQuery = SQLQuery & "WHERE field1 = ? "
SQLQuery = SQLQuery & "AND field2 = ? "
if vSomeVariable = "X" then
SQLQuery1 = " AND field3 in (SELECT f3 FROM sometable2 WHERE f1 = ? AND f2 = ?)"
end if
SQLQuery = SQLQuery & SQLQuery1
...
How to manipulate the ??s of the subquery since it is not always necessary?
I have to mention that I'm talking for a far more complex query structure than my example!
Would you think that it will be better if I write it as a stored function to the database?
Thank you in advance!