首页 > 解决方案 > 在子句Nodejs雪花没有得到结果集

问题描述

我正在用 nodejs 研究雪花。我用过雪花SDK。

我的原始查询是 select * from xyz where x in ('1','2','3'). 为此,在 node.js 中,我编写了查询作为connection.execute({ sqlText: select * from xyz where x in (:1), binds: [] }) 我应该在绑定中传递什么以及以哪种格式,我不知道它是什么?

标签: node.jssnowflake-cloud-data-platform

解决方案


注意:未编译或测试以下内容,但它基于我们使用过的技术

无法直接绑定值数组,但以下方法有效:

变量参数 = ['1', '2', '3']; var 语句 = select * from xyz where id in (${params.map(x => '?').join()});

// 语句现在是: // select * from xyz where id in (?, ?, ?)

connection.execute({ sqlText: statements, binds: params })


推荐阅读