Newbie here. Can someone please help me? I'm trying to use "JSON_TABLE" to convert a json document with arrays into a relational table, but I'm getting the following error. I'm using DB2-Linux v11.1. Thank you in advance.
Error:
"ExampleExceptionFormatter: exception message was: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=path '$.tasks[*]' columns (Ale;.TranId', nested;, DRIVER=4.18.60"
WITH ALERT_TABLE (jsondoc) AS
(
VALUES
'
{
"transaction": {
"TranId": "123"
},
"tasks": [
{
"AlertID": "ABC123",
"AlertType": "AML"
}
,
{
"AlertID": "ZZZ999",
"AlertType": "Fraud"
}
]
}
'
)
SELECT U."TranId", u."AlertID",
u."AlertType"
FROM ALERT_TABLE a, JSON_TABLE
(
a.jsondoc, '$' columns(
TranId INTEGER path '$.TranId',
nested path '$.tasks[*]'
columns (
AlertID VARCHAR(20) path '$.AlertID',
AlertType VARCHAR(20) path
'$.AlertType'
))) u;
I'm expecting to see the following results:
TranId AlertID AlertType
123 ABC123 AML
123 ZZZ999 Fraud