DB2 Version 9.7 for Linux, UNIX, and Windows

xdbDecompXML procedures for annotated schema decomposition

Annotated XML schema decomposition can be invoked by calling one of ten system-defined procedures, which decompose a single XML document.

Annotated XML schema decomposition procedures: These procedures differ only in the size of the xmldoc argument, which specifies the size of the input document to be decomposed. Call the procedure that is just large enough for the size of the document you want to decompose, to minimize system memory usage. For example, to decompose a document 1MB in size, use the xdbDecompXML procedure.

The syntax for xdbDecompXML is presented below; refer to the description of the xmldoc argument for specifications of the xmldoc argument for the xdbDecompXML10MB, xdbDecompXML25MB, xdbDecompXML50MB, xdbDecompXML75MB, xdbDecompXML100MB, xdbDecompXML500MB, xdbDecompXML1GB, xdbDecompXML1_5GB and xdbDecompXML2GB procedures.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-xdbDecompXML--(--rschema--,--xmlschemaname--,--xmldoc--,----->

>--documentid--,--validation--,--reserved--,--reserved--,------->

>--reserved--)-------------------------------------------------><

The schema of the procedure is SYSPROC.

Authorization

The authorization ID belonging to the statement that calls this procedure must have one of the following privileges or authorizations:
  • All of the following privileges:
    • INSERT privilege on all target tables referenced in the annotated schema
    • SELECT, INSERT, UPDATE, or DELETE privilege, as applicable, on any table referenced by the db2-xdb:expression or db2-xdb:condition annotation
  • CONTROL privilege on all target tables referenced in the set of annotated schema documents
  • DATAACCESS authority

If the value of validation is 1, the authorization ID belonging to the statement that calls this procedure must have USAGE privilege on the XML schema.

Procedure parameters

rschema
An input argument of type VARCHAR(128) that specifies the SQL schema part of the two-part XSR object name registered with the XML schema repository. If this value is NULL, then the SQL schema part is assumed to be the current value of the CURRENT SCHEMA special register.
xmlschemaname
An input argument of type VARCHAR(128) that specifies the schema name of the two-part XSR object name registered with the XML schema repository. This value cannot be NULL.
xmldoc
An input argument of type BLOB(1M) that specifies the buffer containing the XML document to be decomposed.
Note:
  • For the xdbDecompXML10MB procedure, this argument is of type BLOB(10M).
  • For the xdbDecompXML25MB procedure, this argument is of type BLOB(25M).
  • For the xdbDecompXML50MB procedure, this argument is of type BLOB(50M).
  • For the xdbDecompXML75MB procedure, this argument is of type BLOB(75M).
  • For the xdbDecompXML100MB procedure, this argument is of type BLOB(100M).
  • For the xdbDecompXML500MB procedure, this argument is of type BLOB(500M).
  • For the xdbDecompXML1GB procedure, this argument is of type BLOB(1G).
  • For the xdbDecompXML1_5GB procedure, this argument is of type BLOB(1.5G).
  • For the xdbDecompXML2GB procedure, this argument is of type BLOB(2G).
documentid
An input argument of type VARCHAR(1024) that specifies the identifier for the input XML document to be decomposed. The value provided in this argument will be substituted for any use of $DECOMP_DOCUMENTID specified in the db2-xdb:expression or db2-xdb:condition annotations in the corresponding XML schema.
validation
An input argument of type INTEGER that indicates whether validation will be performed on the document before it is decomposed. The possible values are:
0
Validation is not performed on the input document before it is decomposed.
1
Validation is performed on the input document against DTDs or XML schema documents previously registered with the XML schema repository. The input XML document is decomposed only if the validation is successful.
reserved
The reserved arguments are input arguments reserved for future use. The values passed for these arguments must be NULL.

Output

There is no explicit output argument for this procedure. Check the sqlcode field of the SQLCA structure for any errors that might have occurred during decomposition. The possible sqlcode values following the completion of decomposition are:
0
Document was successfully decomposed.
positive integer
Document was successfully decomposed, but with warning conditions. The warnings are logged in the db2diag log files, located in the first occurrence data capture (FODC) storage directory.
negative integer
Document could not be decomposed. The sqlcode indicates the reason for the failure. Check the db2diag log files for details of the failure.

Usage notes

The procedures execute with the read stability isolation level.

The procedures run atomically; if a procedure fails during execution, all operations performed by the procedure are rolled back. To commit the changes made by the procedure, the caller must execute the COMMIT SQL statement, as the procedure itself does not execute COMMIT.

If you are using scripts or applications to decompose several documents of which the size is unknown, consider using the DECOMPOSE XML DOCUMENT command to decompose, rather than an xdbDecompXML procedure, as the command automatically calls the appropriate procedure for the size of the document.

Example

The annotated XML schema, which indicates the table and column that the XML values will decompose into, has been registered with the XML schema repository as ABC.TEST. To decompose the XML document into a relational table, call the appropriate procedure as follows:
CALL xdbDecompXML ('ABC', 'TEST', BLOB('<Element1>Hello world</Element1>'), 
     'DOCID', 0 , NULL, NULL, NULL)