Oracle9i Supplied PL/SQL Packages and Types Reference Release 2 (9.2) Part Number A96612-01 |
|
DBMS_XMLGEN, 2 of 2
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 |
---|---|
RETURN ctxHandle; |
Generates a new context handle from a query. |
RETURN ctxHandle; |
Generates a new context handle from a query string in the form of a PL/SQL ref cursor |
Sets the name of the element separating all the rows. The default name is ROW.
User can set this to NULL
to suppress the ROW
element itself. 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.
DBMS_XMLGEN.setRowTag ( ctx IN ctxHandle, rowTag IN VARCHAR2);
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.
DBMS_XMLGEN.setRowSetTag ( ctx IN ctxHandle, rowSetTag IN VARCHAR2);
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 |
---|---|
dtdOrSchema IN number := NONE) RETURN boolean; |
This procedure gets the XML document by fetching the maximum number of rows specified. It appends the XML document to the CLOB passed in. Use this version of getXML() to avoid any extra CLOB copies and to reuse the same CLOB for subsequent calls. Because of the CLOB reuse, this getXML() call is potentially more efficient. |
dtdOrSchema IN number := NONE) RETURN clob; |
Generates the XML document and returns it as a temporary CLOB. The temporary CLOB obtained from this function must be freed using the |
dtdOrSchema IN number := NONE) RETURN clob; |
Converts the results from the SQL query string to XML format, and returns the XML as a temporary CLOB. This temporary CLOB must be subsequently freed using the |
FUNCTION DBMS_XMLGEN.getXMLType ( dtdOrSchema IN number := NONE) RETURN sys.XMLType; |
Generates the XML document and returns it as a |
FUNCTION DBMS_XMLGEN.getXMLType ( dtdOrSchema IN number := NONE) RETURN sys.XMLType |
Converts the results from the SQL query string to XML format, and returns the XML as a |
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.
DBMS_XMLGEN.getNumRowsProcessed ( ctx IN ctxHandle) RETURN NUMBER;
Parameter | IN / OUT | Description |
---|---|---|
ctx |
(IN) |
The context handle obtained from the |
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.
DBMS_XMLGEN.setMaxRows ( ctx IN ctxHandle, maxRows IN NUMBER);
Parameter | IN / OUT | Description |
---|---|---|
ctx |
(IN) |
The context handle corresponding to the query executed. |
maxRows |
(IN) |
The maximum number of rows to get per call to |
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().
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 |
Sets whether or not special characters in the XML data must be converted into their escaped XML equivalent. For example, the <
sign is converted to <.
The default is to perform conversions. Improves performance of XML processing when the input data cannot contain any special characters such as <
, >
, ",
'
, 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 context handle obtained from the |
conv |
(IN) |
|
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 |
---|---|
flag IN NUMBER := ENTITY_ENCODE) RETURN VARCHAR2; |
Uses xmlData in string form (VARCHAR2). |
flag IN NUMBER := ENTITY_ENCODE) RETURN CLOB; |
Uses xmlData in Clob form. |
Parameter | IN / OUT | Description |
---|---|---|
xmlData |
(IN) |
The XML CLOB data to be encoded or decoded. |
flag |
(IN) |
The flag setting; |
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 the collection column name with the _ITEM
tag appended to it.
DBMS_XMLGEN.useItemTagsForColl ( ctx IN ctxHandle);
Parameter | IN / OUT | Description |
---|---|---|
ctx |
(IN) |
The context handle. |
Restarts the query and generates the XML from the first row. Can be used to start executing the query again, without having to create a new context.
DBMS_XMLGEN.restartQUERY (ctx IN ctxHandle);
Parameter | IN / OUT | Description |
---|---|---|
ctx |
(IN) |
The context handle corresponding to the current query. |
Closes a given context and releases all resources associated with it, including the SQL cursor and bind and define buffers. After this call, the handle cannot be used for a subsequent DBMS_XMLGEN
function call.
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. |
|