我将下面的JSON存储在一个BLOB中,在阅读了有关json_table的Oracle文档后,我无法找到获取数据的最佳方法。
{ "filters": [
{
"system": "Givex",
"target_document": "timepunch",
"type": "EXCLUSION",
"key": "job_codes",
"value": "MANAGER",
"description": ""
},
{
"system": "Givex",
"target_document": "menumix",
"type": "EXCLUSION",
"key": "plu_list",
"value": "4,3,5,6,3,22",
"description": ""
}
],
"toggles": [
{
"system": "Givex",
"target_document": "salesmix",
"type": "",
"key": "use_category_not_sub",
"value": "true",
"description": "Will group sales by category not subcategory"
}
]
,
"cross_references": [
{
"system": "Givex",
"target_document": "salesmix",
"type": "",
"key": "GL_MAP",
"values": [
{
"gl_code": "2310",
"txn_name": "AB GST",
"txn_type_id": "1"
},
{
"gl_code": "2310",
"txn_name": "AB GST",
"txn_type_id": "1"
},
{
"gl_code": "1050-1",
"txn_name": "AMEX",
"txn_type_id": "5"
},
{
"gl_code": "1005",
"txn_name": "Actual Cash On Hand",
"txn_type_id": "5"
},
{
"gl_code": "4110",
"txn_name": "Appetizers",
"txn_type_id": "0"
},
{
"gl_code": "2310",
"txn_name": "BC GST",
"txn_type_id": "1"
},
{
"gl_code": "2371",
"txn_name": "BC PST",
"txn_type_id": "1"
},
{
"gl_code": "2371",
"txn_name": "BC PST (10%)",
"txn_type_id": "1"
},
{
"gl_code": "4150",
"txn_name": "Banquets",
"txn_type_id": "0"
}
]
}
]
}
字符串
我试图从cross_references -->values数组中以表格格式获取gl_code、txn_name和txn_type_id的输出,其中键为'GL_MAP'
我尝试过以下方法
select jt.*
from ar_test art,
json_table(art.json_data,'$.cross_references[*]' columns (value path '$.value')) jt
型
却什么也得不到,
select art.json_data.cross_references.value from ar_test art
型
返回null
和
select j.* from
ar_test art,
json_table(art.json_data, '$.cross_references' columns (nested value columns(gl_code,txn_name,txn_type_id))) j
型
它根本不返回任何结果。
任何建议都会很有帮助,因为我是Oracle JSON的新手,有点挣扎:)
谢谢
1条答案
按热度按时间t5zmwmid1#
显然我只是需要多一点时间。
select j. * from ar_test art,json_table(art.json_data,'$.cross_references'列(嵌套值[*]列(gl_code,txn_name,txn_type_id)j;