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!

SYS_REFCURSOR to JSON

Chad BoomJul 19 2018 — edited Jul 30 2018

We are heavily utilizing sys_refcursors for returning results to our JET UI via ORDS. Currently, we build our ref cursors in library packages and then pass them to a custom written package that turns the ref cursor into XML and then uses an XML stylesheet to format it like JSON. We are finding that our queries are executing very quickly, but the dbms_xmlgen.getxmltype is taking a very long time to return. Are there any utilities in the 12.2 database that we could utilize instead of this custom written solution?

  ln\_ctx := dbms\_xmlgen.newcontext(prefcur\_cursor);

  dbms\_xmlgen.setnullhandling(ln\_ctx, dbms\_xmlgen.empty\_tag);

  -- for pagination

  IF pn\_max\_rows IS NOT NULL THEN

    dbms\_xmlgen.setmaxrows(ln\_ctx, pn\_max\_rows);

  END IF;

  IF pn\_skip\_rows IS NOT NULL THEN

    dbms\_xmlgen.setskiprows(ln\_ctx, pn\_skip\_rows);

  END IF;

  -- get the XML content

  lx\_xml := dbms\_xmlgen.getxmltype(ln\_ctx, dbms\_xmlgen.none);

  pn\_rows\_processed := dbms\_xmlgen.getnumrowsprocessed(ln\_ctx);

  dbms\_xmlgen.closecontext(ln\_ctx);

  CLOSE prefcur\_cursor;

pastedImage_0.png

This post has been answered by thatJeffSmith-Oracle on Jul 19 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 27 2018
Added on Jul 19 2018
6 comments
5,559 views