gpt4 book ai didi

json - 函数 json_each 不存在

转载 作者:行者123 更新时间:2023-11-29 11:32:50 25 4
gpt4 key购买 nike

我收到 json_each 函数不存在的错误。我正在使用 postgresql 9.3。我不知道怎么了。请在这里帮助我。

select *
from json_each((
select ed.result
from externaldata ed
inner join
application a
on a.id = ed.application_id

))
limit 1;

内部循环查询返回:

" { "RespuestaSVC89":{
"Header":{
"Transaccion":"EXPE",
"Servicio":"92",
"CodigoRetorno":"00",
"NumeroOperacion":"201409147001616",
"CodigoModelo":"13852901"
},
"meta":{
"billa":"EXPE",
"numo":"52",
"Retorno":"01",
"Operacion":"2014091470",
}
}
}"

所以它应该可以,但不知何故不起作用

确切的错误信息是:

ERROR:  function json_each(text) does not exist
LINE 2: from json_each((
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********

ERROR: function json_each(text) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 15

最佳答案

错误消息指出不存在 json_each(text) 函数,但我知道存在 json_each(json) 函数。关键是将 ed.result 转换为 json 数据类型,如下所示:

select *
from json_each((
select ed.result::json
from externaldata ed
inner join
application a
on a.id = ed.application_id

))
limit 1;

如果您的数据确实都是有效的 json,您可能会考虑将 ed.result 列设为 json 类型(在实际表中)而不是 text 类型。当 9.4 发布时,您几乎肯定会希望使用 jsonb 数据类型来利用该数据类型带来的性能和空间优势。

关于json - 函数 json_each 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27323332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com