jase64
jase6410mo ago

How to pass parameters to SQL query?

In a postgres SQL query like SELECT * FROM <tablename> WHERE id in $1 where $1 is a list of ids I got constantly the error { "error": { "name": "ExecutionErr", "message": "error during execution of the script: db error: ERROR: syntax error at or near "$1"" } } So I tried to enforce $1 to be a string with "$1:TEXT" with same result. Any idea what I'm missing here ?
2 Replies
rubenf
rubenf10mo ago
sql only support parameters supported by the language underneath ah actually that should work you probably need id = ANY($1) and make $1 an array
jase64
jase64OP10mo ago
@rubenf Wonderful it works! For reference, I wrote my query the following way SELECT * FROM <tablename> WHERE id in ANY($1::BIGINT[]) Thnaks a lot!

Did you find this page helpful?