I'm trying to pass an array parameter to the function executeSql of SQLiteObject in ionic to make it as a value for my sql query.
For example
var sqlQuery: string = "SELECT * FROM Property WHERE ID IN (?) AND Status = ?"
var ids: number[] = [123, 321, 456];
and I'm trying to pass it here,
var db: SQLiteObject
db.executeSql(sqlQuery, [ids, 0])
So basically I want to insert all the values of ids to the IN operator and 0 for Status. But I think the SQL interprets it differently.
I tried to pass it as a string db.executeSql(sqlQuery, [ids.toString(), 0])
to remove the unnecessary characters and such. But still it doesn't return anything.
NOTE I know I need it to enclose to a promise or something, but I just sliced it and summarize it to remove the unnecessary codes. Thanks.
I tried to search all over but still can't find a definite answer, I just invent a work around for it by doing this method.
var ids: number[] = [123, 321, 456];
var sqlQuery: string = "SELECT * FROM Property WHERE ID IN (" + ids.toString() + ") AND Status = ?";
And pass it to executeSql
function
var db: SQLiteObject
db.executeSql(sqlQuery, [0]);
This is just a work around. I'll still wait for a better solution. Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With