node.js - 在子句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: [] })
我应该在绑定中传递什么以及以哪种格式,我不知道它是什么?
解决方案
注意:未编译或测试以下内容,但它基于我们使用过的技术
无法直接绑定值数组,但以下方法有效:
变量参数 = ['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 })
推荐阅读
- python - 如何在 Python 中连接多个 32 位哈希字符串并将其转换为唯一标识符
- c# - JSON字符串反序列化为C#对象
- ios - 无法在 Firebase 数据库 iOS 中保存用户
- android - 每次在应用启动时调用 FirebaseAnalytics 的 setUserProperty() 是否安全?
- valgrind - 在 CLion 上使用 Valgrind 和 WSL 时遇到问题
- .net - 是否可以在 WPF 中渲染子级?
- android - Firestore 规则在操场上有效,但不适用于外部请求
- ruby-on-rails - 有没有更好的方法有条件地允许用户使用 ruby on rails 使用“用户名”或“电子邮件”登录?
- django - 在 DRF POST 请求中分配外键
- dompdf - 如何在 PHP 中将 HTML 转换为 PDF 时添加外部 CSS