DBMS_XMLGEN Package → Description of DMS_XMLGEN DBMS_XMLGEN converts the results of a SQL query to a canonical XML format
85 DBMS_XMLGEN → DBMS_XMLGEN converts the results of a SQL query to a canonical XML format. The package takes an … more information on XML support and for an example of how to use DBMS_XMLGEN. This chapter details the following: Functions and Procedures of DBMS_XMLGEN
Functions and Procedures of DBMS_XMLGEN → Table 85-1: Summary of Functions and Procedures of DBMS_XMLGEN Function/Procedure Description
Functions and Procedures of DBMS_XMLGEN → Table 30-1 Summary of Functions and Procedures of DBMS_XMLGEN Function/Procedure Description
newContext() → Generates and returns a new context handle; this context handle is used in getXML() and other functions to get XML back from the result. The available options are given in the table below. Syntax Description DBMS_XMLGEN.newContext ( query IN VARCHAR2) RETURN ctxHandle; Generates a new context handle from a query. DBMS_XMLGEN.newContext ( queryString IN SYS_REFCURSOR) RETURN ctxHandle; Generates a
Description of DMS_XMLGEN → DBMS_XMLGEN converts the results of a SQL query to a canonical XML format. The package takes an
getNumRowsProcessed() → Retrieves the number of SQL rows processed when generating the XML using the getXML call; this count does not include the number of rows skipped before generating the XML. Used to determine the terminating condition if calling getXML() in a loop. Note that getXML() always generates an XML document, even if there are no rows present.
setRowSetTag () → Sets the name of the root element of the document. The default name is ROWSET. User can set the rowSetTag NULL to suppress the printing of this element. However, an error is produced if both the row and the rowset are NULL and there is more than one column or row in the output; this is because the generated XML would not have a top-level enclosing tag, and so would be invalid.
getXML() → Gets the XML document. When the rows indicated by the setSkipRows() call are skipped, the maximum number of rows as specified by the setMaxRows() call (or the entire result if not specified) is fetched and converted to XML. Use the getNumRowsProcessed() to check if any rows were retrieved. The available options are given in the table below. Syntax Description FUNCTION DBMS_XMLGEN.getXML ( ctx IN ctxHandle,
closeContext() → bind and define buffers. After this call, the handle cannot be used for a subsequent DBMS_XMLGEN function call.
setSkipRows() → Skips a given number of rows before generating the XML output for every call to the getXML routine. Used when generating paginated results for stateless Web pages using this utility. For example, when generating the first page of XML or HTML data, set skipRows to zero. For the next set, set the skipRows to the number of rows obtained in the first case. See getNumRowsProcessed().
Syntax → DBMS_XMLGEN.restartQUERY (ctx IN ctxHandle); Parameter IN / OUT Description ctx (IN) The context handle corresponding to the current query.
Syntax → DBMS_XMLGEN.closeContext ( ctx IN ctxHandle); Parameter IN / OUT Description ctx (IN) The context handle to close. Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. Home Book List Contents Index Master Index Feedback
Syntax → DBMS_XMLGEN.setRowSetTag ( ctx IN ctxHandle, rowSetTag IN VARCHAR2); Parameter IN / OUT Description ctx (IN) The context handle obtained from the newContext call. rowSetTag (IN) The name of the document element. Passing NULL indicates that you do not want the ROWSET element present.
convert() → Converts the XML data into the escaped or unescaped XML equivalent; returns XML CLOB data in encoded or decoded format. Escapes the XML data if the ENTITY_ENCODE is specified. For example, the escaped form of the character < is <. Unescaping is the reverse transformation. The available options are given in the table below. Syntax Description DBMS_XMLGEN.convert ( xmlData IN VARCHAR2, flag IN NUMBER:=
Syntax → DBMS_XMLGEN.useItemTagsForColl ( ctx IN ctxHandle); Parameter IN / OUT Description ctx (IN) The context handle.
setConvertSpecialChars() → Sets whether or not special characters in the XML data must be converted into their escaped XML equivalent. For example, the, \", ', which must be escaped. It is expensive to scan the character data to replace the special characters, particularly if it involves a lot of data. Syntax DBMS_XMLGEN.setConvertSpecialChars ( ctx IN ctxHandle, conv IN boolean); Parameter IN / OUT Description ctx (IN) The
useItemTagsForColl() → Overrides the default name of the collection elements. The default name for collection elements is the type name itself. Using this function, you can override the default to use the name of the column with the _ITEM tag appended to it. If there is a collection of NUMBER, the default tag name for the collection elements is NUMBER. Using this procedure, the user can override this behavior and generate
setMaxRows() → Sets the maximum number of rows to fetch from the SQL query result for every invokation of the getXML call. Used when generating paginated results. For example, when generating a page of XML or HTML data, restrict the number of rows converted to XML or HTML by setting the maxRows parameter.
Syntax → DBMS_XMLGEN.setSkipRows ( ctx IN ctxHandle, skipRows IN NUMBER); Parameter IN / OUT Description ctx (IN) The context handle corresponding to the query executed. skipRows (IN) The number of rows to skip per call to getXML.