Executes an arbitrary stored function returning a REF CURSOR and includes the result set in canonical XML format.
XSQL Syntax
<xsql:ref-cursor-function
[ id-attribute="string" ]
[ id-attribute-column="string" ]
[ max-rows="integer" ]
[ null-indicator="boolean" ]
[ row-element="string" ]
[ rowset-element="string" ]
[ skip-rows="integer" ]
[ tag-case="string" ]
>
PLSQL
</xsql:ref-cursor-function>
Examples
The following example executes the stored function returning REF Cursor and include the results in XML format:
<xsql:ref-cursor-function max-rows="5" tag-case="lower"
null-indicator="yes">
flight_schedule.flights_left_today_for(UPPER('{@airport}'));
</xsql:ref-cursor-function>
The following example executes the stored procedure DynamicQuery which returns a cursor to the query.
<xsql:ref-cursor-function>
RefCursorExample.DynamicQuery('{@param1}');
</xsql:ref-cursor-function>
Here is the stored procedure DynamicQuery which returns a cursor to the query:
CREATE OR REPLACE PACKAGE RefCursorExample IS
TYPE ref_cursor IS REF CURSOR;
FUNCTION DynamicQuery(userid VARCHAR2) RETURN ref_cursor;
END;
/
CREATE OR REPLACE PACKAGE BODY RefCursorExample IS
FUNCTION DynamicQuery(userid VARCHAR2) RETURN ref_cursor IS
the_cursor ref_cursor;
my_sal NUMBER := 1;
query VARCHAR2(2000);
BEGIN
IF UPPER(userid) = 'STEVE' THEN
query := 'SELECT ename, sal FROM EMP WHERE ROWNUM < 4';
ELSE
query := 'SELECT dname, deptno FROM DEPT WHERE ROWNUM < 2';
END IF;
OPEN the_cursor FOR query; /* USING var, var, var */
RETURN the_cursor;
END;
END;
/
Description
Executes an arbitrary stored function returning a REF CURSOR and includes the result set in canonical XML format. Use the wizard's Query panel to enter the required PL/SQL code or the name of a stored procedure.
Use this tag to invoke a stored procedure that determines what the query is and returns a cursor to the query. Used in this way, this tag also provides a weak level of security in that it can hide the query from direct inspection. See the Examples for more information.
Attributes
Note: If you set both row-element and rowset-elementto a blank value (" ") and perform a a query that returns more than one row, then the parser will return an ill-formed document error.