IBM DB2 Manual page 165

Table of Contents

Advertisement

Table 22. SQLXML and DB2Xml methods, data types, and added encoding specifications (continued)
Method
SQLXML.getCharacterStream
SQLXML.getSource
SQLXML.getString
DB2Xml.getDB2AsciiStream
DB2Xml.getDB2BinaryStream
DB2Xml.getDB2Bytes
DB2Xml.getDB2CharacterStream
DB2Xml.getDB2String
DB2Xml.getDB2XmlAsciiStream
DB2Xml.getDB2XmlBinaryStream
DB2Xml.getDB2XmlBytes
DB2Xml.getDB2XmlCharacterStream
DB2Xml.getDB2XmlString
If the application executes the XMLSERIALIZE function on the data that is to be
returned, after execution of the function, the data has the data type that is specified
in the XMLSERIALIZE function, not the XML data type. Therefore, the driver
handles the data as the specified type and ignores any internal encoding
declarations.
Example: Suppose that you retrieve data from an XML column into a String host
expression.
#sql iterator XmlStringIter (int, String);
#sql [ctx] siter = {SELECT C1, CADOC from CUSTACC};
#sql {FETCH :siter INTO :row, :outString};
The String type is a character type, so the data is converted from UTF-8 to the
external encoding, which is the default JVM encoding, and returned without any
XML declaration.
Example: Suppose that you retrieve data from an XML column into a byte[] host
expression.
#sql iterator XmlByteArrayIter (int, byte[]);
XmlByteArrayIter biter = null;
#sql [ctx] biter = {SELECT c1, CADOC from CUSTACC};
#sql {FETCH :biter INTO :row, :outBytes};
The byte[] type is a binary type, so no data conversion from UTF-8 encoding
occurs, and the data is returned without any XML declaration.
Example: Suppose that you retrieve a document from an XML column into a
java.sql.SQLXML host expression, but you need the data in a binary stream.
#sql iterator SqlXmlIter (int, java.sql.SQLXML);
SqlXmlIter SQLXMLiter = null;
java.sql.SQLXML outSqlXml = null;
#sql [ctx] SqlXmlIter = {SELECT c1, CADOC from CUSTACC};
#sql {FETCH :SqlXmlIter INTO :row, :outSqlXml};
java.io.InputStream XmlStream = outSqlXml.getBinaryStream();
Output data type
Type of XML internal encoding declaration added
Reader
None
Source
None
String
None
InputStream
None
InputStream
None
byte[]
None
Reader
None
String
None
InputStream
US-ASCII
InputStream
Specified by getDB2XmlBinaryStream targetEncoding
parameter
byte[]
Specified by DB2Xml.getDB2XmlBytes targetEncoding
parameter
Reader
ISO-10646-UCS-2
String
ISO-10646-UCS-2
Chapter 4. SQLJ application programming
149

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents