Skip to content
Advertisement

Oracle 12c Json split

This is how I am getting result in Oracle 12c

Id Start Date Range End Date Range
1 [ “2019-01-07″,”2019-02-17″,”2019-03-17”] [ “2019-01-14″,”2019-02-21″,”2019-03-21”]

And I want it

Id Start Date Range End Date Range
1 2019-01-07 2019-01-14
1 2019-02-17 2019-02-21
1 2019-03-17 2019-03-21

Earlier I had asked this question for single-column split and below is the link How to replace special characters and then break line in oracle But when I add another column there is the cartesian product.

Advertisement

Answer

You can use json_table to extract the strings from the JSON arrays, presumably as actual dates:

The for ordinality clauses provide an index into each array, and the join then matches up the ‘related’ array entries.

If you want string rather than dates for some reason you can just change the data type in the column clauses.

db<>fiddle

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement