javascript - 单引号中的 Javascript 查询字符串
问题描述
我在使用字符串时遇到了一些问题,我总是 在 """" 处或附近得到错误的零长度分隔标识符
我想要这个查询是 JSON 格式的结果,使用这个参考
https://sikandar89dubey.wordpress.com/2015/12/23/how-to-dump-data-from-redshift-to-json/
我在 dbeaver 中运行查询是工作
这是我在 dbeaver 中的代码
UNLOAD ('SELECT \'{ \' ||
case when "id" is null then \'\' else \'"id": "\' || "id" END ||
case when "topid" is null then \'\' else \'", "topid": \' || "topid" END ||
case when "parentid" is null then \'\' else \', "parentid": \' || "parentid" END ||
case when "category" is null then \'\' else \', "category": "\' || "category" END ||
case when "createdon" is null then \'\' else \'", "createdon": "\' || "createdon" END ||
case when "updatedon" is null then \'\' else \'", "updatedon": "\' || "updatedon" END ||
\'" }\' FROM table')
但是当我在 javascript 中尝试时,它的错误是我在 javascript 中的查询
`UNLOAD ('SELECT \"{ \" ||
case when \"id\" is null then \'\' else \"\"id\": \"\" || \"id\" END ||
case when \"topid\" is null then \'\' else \"\", \"topid\": \" || \"topid\" END ||
case when \"parentid\" is null then \'\' else \", \"parentid\": \" || \"parentid\" END ||
case when \"category\" is null then \'\' else \", \"category\": \"\" || \"category\" END ||
case when \"createdon\" is null then \'\' else \"\", \"createdon\": \"\" || \"createdon\" END ||
case when \"updatedon\" is null then \'\' else \"\", \"updatedon\": \"\" || \"updatedon\" END ||
\"\" }\" FROM table')`
解决方案
推荐阅读
- .net - Build pipeline for service fabric app on Azure devops
- android - 错误:程序类型已存在:okhttp3.Address
- javascript - Node to Array in DOM JS, how it works?
- java - cURL POST 命令无响应
- javascript - CSV 从网站下载到 R,访问直接链接
- go - Double checked locking in golang - Why mutex.RLock() is required?
- css - CSS 过渡仅在开发工具打开时有效
- angular - Angular select element looses default value when using [ngValue]
- sql - SQL - joining 3 tables
- java - 编译时出错:- 表达式的类型必须是数组类型,但它被解析为 Object