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;
