问题描述
大家好,
我有一个问题从JSON列基于键检索数据。在json下面找到。我已经验证了JSON。我没有发现JSON的任何问题。
oracle table中的JSON字段为CLOB类型。
两个查询都返回一个null值。任何帮助将不胜感激。
问候
帕万
我有一个问题从JSON列基于键检索数据。在json下面找到。我已经验证了JSON。我没有发现JSON的任何问题。
"{
"Test": "123.40.4",
"allowedtables": [{
"name": "t",
"attributes": {
"l": "A"
},
"groups": [{
"name": "grp",
"attributes": {
"n": "AI"
},
"categories": [{
"name": "cat",
"attributes": {
"n": "50"
},
"columns": [{
"name": "col",
"attributes": {
"n": "AO"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "536"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "60"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "3"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "70"
},
"columns": [{
"name": "col",
"attributes": {
"n": "DT"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "2017-12-31"
}]
}]
}]
},
{
"name": "grp",
"attributes": {
"n": "CL"
},
"categories": [{
"name": "cat",
"attributes": {
"n": "100"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "110"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "120"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "0"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "130"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "140"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "150"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "160"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "3"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "170"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "180"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "190"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "2"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "200"
},
"columns": [{
"name": "col",
"attributes": {
"n": "C"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "1"
}]
}]
}]
},
{
"name": "grp",
"attributes": {
"n": "ID"
},
"categories": [{
"name": "cat",
"attributes": {
"n": "10"
},
"columns": [{
"name": "col",
"attributes": {
"n": "H"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "102"
}]
},
{
"name": "col",
"attributes": {
"n": "R"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "861"
}]
},
{
"name": "col",
"attributes": {
"n": "S"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "17"
}]
}]
}]
},
{
"name": "grp",
"attributes": {
"n": "LO"
},
"categories": [{
"name": "cat",
"attributes": {
"n": "20"
},
"columns": [{
"name": "col",
"attributes": {
"n": "DG"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "43"
}]
},
{
"name": "col",
"attributes": {
"n": "MI"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "27"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "30"
},
"columns": [{
"name": "col",
"attributes": {
"n": "DG"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "16"
}]
},
{
"name": "col",
"attributes": {
"n": "MI"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "42"
}]
}]
},
{
"name": "cat",
"attributes": {
"n": "40"
},
"columns": [{
"name": "col",
"attributes": {
"n": "N"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "HR035"
}]
}]
}]
},
{
"name": "grp",
"attributes": {
"n": "Test"
},
"categories": [{
"name": "cat",
"attributes": {
"n": "10"
},
"columns": [{
"name": "col",
"attributes": {
"n": "H"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "102"
}]
},
{
"name": "col",
"attributes": {
"n": "R"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "861"
}]
},
{
"name": "col",
"attributes": {
"n": "S"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "17"
}]
}]
}]
},
{
"name": "grp",
"attributes": {
"n": "Test"
},
"categories": [{
"name": "cat",
"attributes": {
"n": "10"
},
"columns": [{
"name": "col",
"attributes": {
"n": "H"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "102"
}]
},
{
"name": "col",
"attributes": {
"n": "R"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "861"
}]
},
{
"name": "col",
"attributes": {
"n": "S"
},
"values": [{
"value": "col_value",
"attributes": null,
"data": "17"
}]
}]
}]
}]
}]
}"
select getJSON.ColumnName.allowedtables from R1_TESTJSON getJSON
where getJSON.ColumnName.Test = '123.40.4';
select getJSON.ColumnName.allowedtables[*] from R1_TESTJSON getJSON
where getJSON.ColumnName.Test = '123.40.4';oracle table中的JSON字段为CLOB类型。
两个查询都返回一个null值。任何帮助将不胜感激。
问候
帕万
专家解答
Eee,那是一个大的JSON文档!
这就是你问题的根源。点符号总是返回一个varchar2(4000)。你要退回的文件比那还大!
通过使用json_query并指定更大的varchar2来解决这个问题:
这就是你问题的根源。点符号总是返回一个varchar2(4000)。你要退回的文件比那还大!
通过使用json_query并指定更大的varchar2来解决这个问题:
select length (
json_query (
TestJSON, '$.allowedtables'
returning varchar2(32767)
error on error
)
) l ,
json_query (
TestJSON, '$.allowedtables'
returning varchar2(32767)
error on error
) doc
from R1_TESTJSON getJSON
where getJSON.TestJSON.Test = '121.00.101';
L DOC
4247 [{"name":"t","attributes":{"l":"A"},"groups":[ ... 文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




