我在nodejs中使用aws sdk并在aws lamdba中运行以下查询,该查询在使用参数数组时不起作用:
executeStatement({
Statement: `select * from "myTable"."myIndex" where "pk" = '?' and "sortKey5" >= 50 ORDER BY "sortKey5" DESC`,
Parameters: [{"S": pk}] })使用直接内联参数的相同查询可以正常工作
executeStatement({
Statement: `select * from "myTable"."myIndex" where "pk" = 'xxx' and "sortKey5" >= 50 ORDER BY "sortKey5" DESC` })可能是“?”的语法问题。这是错误的,但我找不到任何使用其他语法的示例。
有人知道如何编写语句以便使用参数吗?
发布于 2021-08-31 07:53:02
看起来,至少在SELECT语句中,需要省略?两边的单引号,例如foobar = ?而不是foobar = '?'。
因此,您的查询将是:
executeStatement({
Statement: `select * from "myTable"."myIndex" where "pk" = ? and "sortKey5" >= 50 ORDER BY "sortKey5" DESC`,
Parameters: [{"S": pk}]
})https://stackoverflow.com/questions/68990050
复制相似问题