i have clob column following data (simplified purposes of question)
{ "notused": [], "stock": [ { "name": "eggs", "value": "in stock" }, { "name": "milk", "value": "out of stock" } ] }
i want avoid having select entire object , parse programatically data want. ideally i'd make use of oracle json path features this.
i want "value"
, "name" = "eggs"
i have tried following, [99999][40442] ora-40442: json path expression syntax error
. have run above example json, , json path through evaluator , returns desired result, makes me think oracle has it's own jsonpath intepretation
select json_query( '{"notused":[],"stock":[{"name":"eggs","value":"in stock"}, {"name":"milk","value":"out of stock"}]}', '$.stock[?(@.name=="eggs")]' ) dual;
i have tried using dot notation, haven't been able find example covers adding clause properties of array.
select mytable.id, mytable.json_column.stock -- how array element here? my_table mytable j.id = 46
version:
select * v$version oracle database 12c enterprise edition release 12.1.0.2.0 - 64bit production pl/sql release 12.1.0.2.0 - production "core 12.1.0.2.0 production"
the json_path_expression supports basic syntax, according the manual:
json_path_expression::=
object_step::=
array_step::=
an alternative approach use json_table convert json relational table , project , filter columns.
select value json_table( '{ "notused": [], "stock": [ { "name": "eggs", "value": "in stock" }, { "name": "milk", "value": "out of stock" } ] }', '$.stock[*]' columns ( name varchar2(100 char) path '$.name', value varchar2(100 char) path '$.value' ) ) name = 'eggs'
results:
value ----- in stock
Comments
Post a Comment