I have a complex Json file (in a CLOB). I'll try to make it esential:
{
"c1": "c1",
"c2": "c2",
"c3": {
"a": "a"
},
"c4": {
"c5": {
"c6": "c6"
}
}
}
So I have a query like this:
SELECT tabj.*
FROM table_with_clob_column t,
JSON_TABLE(
t.clob_with_json_file,
'$' COLUMNS(
c1,
c2,
NESTED c3 COLUMNS(a),
NESTED c4.c5 COLUMNS(c6)
)
) tabj
WHERE t.id = 1; -- just one row in t table
The problem is that I get more than one row:
| c1 | c2 | a | c6 |
|---|---|---|---|
| c1 | c2 | a | |
| c1 | c2 | c6 |
I need one row:
| c1 | c2 | a | c6 |
|---|---|---|---|
| c1 | c2 | a | c6 |
You do not appear to need to use
NESTED, instead use the path to reference the descendant attributes directly:Which, for the sample data:
Outputs:
fiddle