I have the following query with the aws sdk in nodejs and running in aws lamdba that doesn't work when using the parameters array:
executeStatement({
Statement: `select * from "myTable"."myIndex" where "pk" = '?' and "sortKey5" >= 50 ORDER BY "sortKey5" DESC`,
Parameters: [{"S": pk}] })
the same query with the parameter directly inline works
executeStatement({
Statement: `select * from "myTable"."myIndex" where "pk" = 'xxx' and "sortKey5" >= 50 ORDER BY "sortKey5" DESC` })
it's probably the syntax with '?' that is wrong but I couldn't find any sample with an other syntax.
does any one knows how to write the statement so that it uses the parameter?
It seems that, at least in a SELECT statement, one needs to omit the single-quotes around the ?, e.g. foobar = ? rather than foobar = '?'.
So your query would be:
executeStatement({
Statement: `select * from "myTable"."myIndex" where "pk" = ? and "sortKey5" >= 50 ORDER BY "sortKey5" DESC`,
Parameters: [{"S": pk}]
})
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