XML data in embedded SQL applications
Embedded SQL applications that are written in assembler language, C, C++, COBOL, or PL/I can update and retrieve data in XML columns.
In embedded SQL applications, you can:
- Store an entire XML document in an XML column using INSERT or UPDATE statements.
- Retrieve an entire XML document from an XML column using SELECT statements.
- Retrieve a sequence from a document in an XML column by using the SQL XMLQUERY function within a SELECT or FETCH statement, to retrieve the sequence into a textual XML string in the database, and then retrieve the data into an application variable.
Recommendation: Follow these guidelines when you write embedded
SQL applications:
- Avoid using the XMLPARSE and XMLSERIALIZE functions.
Let Db2 do the conversions between the external and internal XML formats implicitly.
- Use XML host variables for input and output.
Doing so allows Db2 to process values as XML data instead of character or binary string data. If the application cannot use XML host variables, it should use binary string host variables to minimize character conversion issues.
- Avoid character conversion by using UTF-8 host variables for input and output of XML values whenever possible.