I have a Oracle 12c Database with a table like this
(
MSISDN VARCHAR2(15 BYTE),
DOCUMENT VARCHAR2(15 BYTE),
LOAD_DATE DATE,
LIST_NAME VARCHAR2(40 BYTE),
ATRIB VARCHAR2(40 BYTE),
VALUE VARCHAR2(200 BYTE)
)
In the other hand, I have this JSON who contain the data for that table
{
"DigitalClient":{
"documentNumber":"99999999-R",
"documentType":"PASSPORT",
"lastLineDate":123213213213,
"lastClientDate":123213213213,
"segment":"EMPRESA"
},
"ADSL":{
"idOrder":216668542,
"status":"COMPLETED",
"orderType":"STANDARD",
"documentNumber":"161893223R",
"technologyAccess":"FTTVULA",
"dUserLastModifiedDate":1571329345000,
"type":"PERSON"
}
}
The idea is to parse this info in the table in this way:
MSISDN DOCUMENT LOAD_DATE LIST_NAME ATRIB VALUE
------ --------- ----------- ------------ -------- -----
911231231 6745671A 05/12/19 DigitalClient documentNumber 99999999R
911231231 6745671A 05/12/19 DigitalClient documentType PASSPORT
911231231 6745671A 05/12/19 ADSL idOrder 216668542
...
The three first fields are obtained outside of the JSON file, the JSON file related fields are the last three. As you can see, the field LIST_NAME is filled with the first level name, and the ATRIB and VALUE fields are filled with the second level name and value
Now, the hard part. The JSON structure change every day. I don't know what the JSON file contains, neither first or second levels field names nor how many structures come. The only thing I know is that the file has only 2 levels deep: first for the name of a list of attributes, and second for the attributes and their values of each list.
Anyone knows a good way to achieve this? I tried with the solution showed here but is not what I'm looking for, because I must extract the LIST_NAME and ATRIB info using a SUBSTR in the first column, and is not very efficient for loading a large bunch of records.
Thanks in advance!