in Education by
I have a CLOB column with the following data (simplified for the purposes of this question) { "notUsed": [], "stock": [ { "name": "eggs", "value": "in stock" }, { "name": "milk", "value": "out of stock" } ] } I want to avoid having to select the entire object and parse programatically to get the data I want. Ideally I'd like to make use of the Oracle JSON path features to do this. I want to get "value", where "name" = "eggs" I have tried the following, but get a [99999][40442] ORA-40442: JSON path expression syntax error. I have run the above example JSON, and JSON path through an evaluator and it returns the desired result, which 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")]' ) FROM dual; I have also tried using the Dot Notation, but haven't been able to find an example that covers adding a where clause to properties of an array. select myTable.id, myTable.JSON_COLUMN.stock -- how to get array element here? from MY_TABLE myTable where j.id = 46 Version: SELECT * FROM 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" JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The JSON_path_expression only supports some basic syntax, according to the manual: JSON_path_expression::= object_step::= array_step::= An alternative approach is to use JSON_TABLE to convert the JSON into a relational table and then project and filter the columns. select value from 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' ) ) where name = 'eggs' Results: VALUE ----- in stock

Related questions

0 votes
    If I want to hold a Teams meeting and invite “guests,” what happens if I select that only specific domains ... still able to join the Teams meeting from via a link?...
asked Mar 10, 2021 in Technology by JackTerrance
0 votes
    Which of the following function of Array object removes the last element from an array and returns that element? push() delete() pop() link()...
asked Dec 24, 2020 in Technology by JackTerrance
0 votes
    I was unable to find a solution that is identical with the issue I am trying to solve. If is a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have the following stored in an Oracle database as JSON: { value: [1,2,3] } The value can be ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I was unable to find a solution that is identical with the issue I am trying to solve. If is a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm stuck at the point of parsing a JSON array of dicts (http://www.cjs-design.nl/json.php) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have a certain element that I can select with Selenium 1. Unfortunately, I need to click the parent element ... upwards with XPath? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    The ___________ class adds a rounded border around an element with a gray background color and some padding. ... .alert .jumbotron Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a field call query_data defined as text in my MySQL database. In my model I defined this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
...