Below is example kind of data. Is there any way to get value only id from below json array.
Env: DB2 query TABLE NAME: RTN_PRD COLUMN NAME : DTL_PRD
{"ProductList":"[{\"ID\":\"1111\",\"Product\":\"A001\"} ,{\"ID\":\"222\",\"Product\":\"A002\"} ,{\"ID\":\"333\",\"Product\":\"A003\"}]"}
I have tried below solution, but error.
SELECT
P.ID_PROD
FROM
RTN_PRD,
JSON_TABLE
( JSON_VALUE ( DTL_PRD,'$.ProductList[*]' )
COLUMNS (
ID_PROD varchar (100) PATH '$.ID')
) P
'strict $',error on error) are missing, but DB2LUW does not provide a simple way to extract data from JSON arrays. You can find a solution here. If you are using DB2 for Z/OS maybe this will work too. With DB2 for IBMi you can use nested path clause