【发布时间】:2021-03-06 10:40:00
【问题描述】:
我正在尝试使用对 PostgreSQL 的 openquery 在 MS SQL Server 中检索一些特定数据。
PostgreSQL 中的那个表有一个包含 JSON 数据的字段。
select * from openquery ( PG_DOCTORCASH_PRODUCTION, '
select
id as webappid
,created_at+interval ''8 hours'' as webapp_created_dttm
,response_body::json->>''status'' as status
from terrasoft_logs
where type like ''Terrasoft::Clients::CreditInformation%''
and response_body::json->>''status'' in (''3'', ''4'', ''1005'',''13'')
and item_type = ''Client''
and status_code = ''200''
and cast (updated_at+interval ''8 hours'' as date) >= cast(now() at time zone ''utc''+interval ''8 hours'' as date)-interval ''30 days''
limit 100')
一切正常,但是当我想抓取放在 JSON(嵌套)的某些元素中的抓取字段时,一切都出错了。
我想知道如何使用上面使用的语法获取数据
,response_body::json->>''status'' as status
但是使用类似的语法对我没有帮助(下)。
response_body::json#>>''{data,10}''
请写信给我可以做到的操作员。我想我只能使用运算符在 JSON 树中挖掘。
【问题讨论】:
标签: json sql-server postgresql openquery