Skip to Main Content

ORDS, SODA & JSON in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

refcursor-json

User_BSEZ8Apr 1 2022 — edited Apr 1 2022

Hi!
We use ords version 21.4.2.r0621806 and pl/sql packages returning one ref cursor.
Example
declare
l_cur SYS_REFCURSOR;
begin
open l_cur for
Select JSON_OBJECTAGG( DEPARTMENT_NAME VALUE
( select JSON_ARRAYAGG( JSON_OBJECT('name' VALUE FIRST_NAME,
'lastname' value LAST_NAME,
'email' value EMAIL) )

from EMPLOYEES e where e.DEPARTMENT\_ID = d.DEPARTMENT\_ID ) returning clob    

) as

from DEPARTMENTS d;
:res := l_cur;

end;

If I add the "{}test" at the end the output will be json but it will also add a add "test" o the output.
"
returning clob
) as "{}test"
from DEPARTMENTS d;
"

image.pngHow can we achieve this without the extra level in json output still using pl/sql package and one out ref cursor ?
I can use sys.htp.prn ( I think) but we want to use the ORDS stuff.
Best regards Ola

This post has been answered by thatJeffSmith-Oracle on Apr 1 2022
Jump to Answer
Comments
Post Details
Added on Apr 1 2022
3 comments
557 views