I use this code to record a JSON datas to a Oracle Database
SELECT NOM, PRENOMS, DATE_NAISS
FROM JSON_TABLE('[
{
"Id": 123,
"Nom": "Toto",
"Prenoms": [
"Pascal",
"Vincent"
],
"DateNaissance": "1983-01-01T00:00:00"
}]', '$[*]' COLUMNS
(
"NOM" PATH '$.Nom',
"PRENOMS" PATH '$.Prenoms',
"DATE_NAISS" DATE PATH '$.DateNaissance'
) ) T_JSON;
and i want to concat the elements of field "Prenoms" like this
[ {
"Id": 123,
"Nom": "Toto",
"Prenoms": "Pascal, Vincent",
"DateNaissance": "1983-01-01T00:00:00",
} ]
could you help me, please ?
thanks
"PRENOMS" varchar2(100) FORMAT JSON PATH ‘$."Prenoms"[*]’
the Code i try but it’s not ok, that’s return empty string
2
Answers
Extract the
prenoms
array as an array and then split it separately and then aggregate it into your desired format:Which outputs:
If you want it back in JSON format then:
Which outputs:
fiddle
You can also do it using nested path:
and then