I have query which will fetch the output in JSON string, it works fine when i query it with one value.
But throws an error when i query for all the fields.
ORA-01489: result of string concatenation is too long
What is wrong with my query?
Query:
with ABC_ELEMETNS as
(
select '{'
||' "id":"'||A.PR||'"'
||' "de":"'||A.AA||'"'
||' "r":"'||A.BB||'"'
||' "r":"'||A.CC||'"'
||' "y":"'||A.DD||'"'
||'} ' json
from A
left join B on A.EE = B.EE
where A.EE = 12345
)
select '{"ELEMENTS":['
||(select listagg(json, ',')
within group (order by 1)
from ABC_ELEMENTS)
||']}'
from DUAL;