Total Pageviews

2020/07/08

[Oracle] Retrieving JSON in Oracle

Problem
Assume I would like to select a CLOB column with JSON value, it looks like:

{
 "test_no":"9999",
 "year":"0108",
 "registerDate":"20191031"
}

How to select test_no value (i.e. "9999") in Oracle?


How-To
Using JSON_VALUE to fulfill this requirement:

SELECT JSON_VALUE(JSON_COLUMN, '$.test_no' RETURNING VARCHAR2) 
FROM test_table


Reference
https://www.red-gate.com/simple-talk/sql/oracle/json-for-absolute-beginners-part-4-retrieving-json-in-oracle/

No comments: