PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
DBMS_XMLQUERY
provides database-to-XMLType
functionality. Whenever possible, use DBMS_XMLGEN
, a built-in package in C, instead of DBMS_XMLQUERY
.
This chapter contains the following topics:
Type | Description |
---|---|
ctxType |
The type of the query context handle. This is the return type of |
Closes or deallocates a particular query context
PROCEDURE closeContext( ctxHdl IN ctxType);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
Generates and returns the DTD based on the SQL query used to initialize the context. The options are described in the following table.
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
withVer |
(IN) |
Generate the version information? |
xDoc |
(IN) |
|
Returns the thrown exception's SQL error code and error message through the procedure's OUT
parameters. This procedure is a work around the JVM functionality that obscures the original exception by its own exception, rendering PL/SQL unable to access the original exception content.
PROCEDURE getExceptionContent( ctxHdl IN ctxType, errNo OUT NUMBER, errMsg OUT VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
errNo |
(OUT) |
Error number. |
errMsg |
(OUT) |
Error message. |
Return the number of rows processed for the query.
FUNCTION getNumRowsProcessed( ctxHdl IN ctxType) RETURN NUMBER;
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
Prints the version of the XSU in use.
PROCEDURE getVersion();
Creates the new context, executes the query, gets the XML back and closes the context. This is a convenience function. The context doesn't have to be explicitly opened or closed. The options are described in the following table.
Creates a query context and it returns the context handle. The options are described in the following table.
Parameter | IN / OUT | Description |
---|---|---|
sqlQuery |
(IN) |
SQL query, the results of which to convert to XML. |
Specifies whether to throw every original exception raised or to wrap it in an OracleXMLSQLException
.
PROCEDURE propagateOriginalException( ctxHdl IN ctxType, flag IN BOOLEAN);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
flag |
(IN) |
|
Removes the value of a top-level stylesheet parameter. If no stylesheet is registered, this method is not operational.
PROCEDURE removeXSLTParam( ctxHdl IN ctxType, name IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
name |
(IN) |
Name of the top level stylesheet parameter. |
Sets a value for a particular bind name.
PROCEDURE setBindValue( ctxHdl IN ctxType, bindName IN VARCHAR2, bindValue IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
bindName |
(IN) |
Bind name. |
bindValue |
(IN) |
Bind value. |
Sets the name of the id attribute of the collection element's separator tag. Passing NULL
or an empty string for the tag causes the row id attribute to be omitted.
PROCEDURE setCollIdAttrName( ctxHdl IN ctxType, attrName IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
attrName |
(IN) |
Attribute name. |
Sets the XML data header. The data header is an XML entity that is appended at the beginning of the query-generated XML entity, the rowset
. The two entities are enclosed by the docTag
argument. The last data header specified is used. Passing in NULL
for the header
parameter unsets the data header.
PROCEDURE setDataHeader( ctxHdl IN ctxType, header IN CLOB := null, tag IN VARCHAR2 := null);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
header |
(IN) |
Header. |
tag |
(IN) |
Tag used to enclose the data header and the rowset. |
Sets the format of the generated dates in the XML document. The syntax of the date format pattern, the date mask, should conform to the requirements of the java.text.SimpleDateFormat
class. Setting the mask to NULL
or an empty string sets the default mask -- DEFAULT_DATE_FORMAT
.
PROCEDURE setDateFormat( ctxHdl IN ctxType, mask IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
mask |
(IN) |
The date mask. |
Sets the encoding processing instruction in the XML document.
PROCEDURE setEncodingTag( ctxHdl IN ctxType, enc IN VARCHAR2 := DB_ENCODING);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
enc |
(IN) |
The encoding to use. |
Sets the tag to be used to enclose the XML error documents.
PROCEDURE setErrorTag( ctxHdl IN ctxType, tag IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
tag |
(IN) |
Tag name. |
Sets the maximum number of rows to be converted to XML. By default, there is no set maximum.
PROCEDURE setMaxRows ( ctxHdl IN ctxType, rows IN NUMBER);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
rows |
(IN) |
Maximum number of rows to generate. |
Sets the XML meta header. When set, the header is inserted at the beginning of the metadata part (DTD or XMLSchema) of each XML document generated by this object. The last meta header specified is used. Passing in NULL
for the header
parameter unsets the meta header.
PROCEDURE setMetaHeader( ctxHdl IN ctxType, header IN CLOB := null);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
Header |
(IN) |
Header. |
Specifies whether to throw raised exceptions. If this call isn't made or if FALSE
is passed to the flag
argument, the XSU catches the SQL exceptions and generates an XML document from the exception message.
PROCEDURE setRaiseException( ctxHdl IN ctxType, flag IN BOOLEAN:=true);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
flag |
(IN) |
Throw raised exceptions? |
Specifies whether to throw an OracleXMLNoRowsException
when the generated XML document is empty. By default, the exception is not thrown.
PROCEDURE setRaiseNoRowsException( ctxHdl IN ctxType, flag IN BOOLEAN:=false);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
flag |
(IN) |
Throws an |
Sets the name of the id attribute of the row enclosing tag. Passing NULL
or an empty string for the tag causes the row id attribute to be omitted.
PROCEDURE setRowIdAttrName( ctxHdl IN ctxType, attrName IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
attrName |
(IN) |
Attribute name. |
Specifies the scalar column whose value is to be assigned to the id attribute of the row enclosing tag. Passing NULL
or an empty string for the colName
assigns the row count value (0, 1, 2 and so on) to the row id attribute.
PROCEDURE setRowIdAttrValue( ctxHdl IN ctxType, colName IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
colName |
(IN) |
Column whose value is to be assigned to the row id attribute. |
Sets the tag to be used to enclose the XML dataset.
PROCEDURE setRowsetTag( ctxHdl IN ctxType, tag IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
tag |
(IN) |
Tag name. |
Sets the tag to be used to enclose the XML element corresponding to a db.record
.
PROCEDURE setRowTag( ctxHdl IN ctxType, tag IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
tag |
(IN) |
Tag name. |
Sets the number of rows to skip. By default, 0 rows are skipped.
PROCEDURE setSkipRows( ctxHdl IN ctxType, rows IN NUMBER);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
rows |
(IN) |
Maximum number of rows to skip. |
This turns on or off escaping of XML tags in the case that the SQL object name, which is mapped to a XML identifier, is not a valid XML identifier.
PROCEDURE setSQLToXMLNameEscaping( ctxHdl IN ctxType, flag IN BOOLEAN := true);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
flag |
(IN) |
Turn on escaping? |
Sets the stylesheet header (the stylesheet processing instructions) in the generated XML document. Passing NULL
for the uri
argument will unset the stylesheet header and the stylesheet type.
PROCEDURE setStylesheetHeader( ctxHdl IN ctxType, uri IN VARCHAR2, type IN VARCHAR2 := 'text/xsl');
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
uri |
(IN) |
Stylesheet URI. |
type |
(IN) |
Stylesheet type; defaults to " |
Specifies the case of the generated XML tags.
PROCEDURE setTagCase( ctxHdl IN ctxType, tCase IN NUMBER);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
tCase |
(IN) |
The tag's case: |
Registers a stylesheet to be applied to generated XML. If a stylesheet was already registered, it is replaced by the new one. The options are described in the following table. Passing NULL
for the uri
argument or an empty string for the stylesheet
argument will unset the stylesheet header and type.
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
uri |
(IN) |
Stylesheet URI. |
stylesheet |
(IN) |
Stylesheet. |
ref |
(IN) |
URL to include, imported and external entities. |
Sets the value of a top-level stylesheet parameter. The parameter value is expected to be a valid XPath expression; the string literal values would therefore have to be quoted explicitly. If no stylesheet is registered, this method is not operational.
PROCEDURE setXSLTParam( ctxHdl IN ctxType, name IN VARCHAR2, value IN VARCHAR2);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
name |
(IN) |
Name of the top level stylesheet parameter. |
value |
(IN) |
Value to be assigned to the stylesheet parameter. |
Specifies whether to use an XML attribute to indicate NULL
ness, or to do this by omitting the particular entity in the XML document.
PROCEDURE setNullAttributeIndicator( ctxHdl IN ctxType, flag IN BOOLEAN);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
flag |
(IN) |
Sets attribute to |
Specifies whether to use the collection element's type name as its element tag name. By default, the tag name for elements of a collection is the collection's tag name followed by _item
.
PROCEDURE useTypeForCollElemTag( ctxHdl IN ctxType, flag IN BOOLEAN := true);
Parameter | IN / OUT | Description |
---|---|---|
ctxHdl |
(IN) |
Context handle. |
flag |
(IN) |
Turn on use of the type name? |