Databases Reference
In-Depth Information
printf(" FAILED WITH SQLCODE = %d\n\n", sqlca.sqlcode);
}
EXEC SQL COMMIT;
/* disconnect from the database */
EXEC SQL CONNECT RESET;
} /* main */
In Example 4-38 on page 195, we declare a host variable of XML as CLOB. The
bind file resulting from the db2 prep utility results in the following db2bfd -v
command output:
updtProd.bnd: Host Variables = 3
Type SQL Data Type Length Alias Name_Len Name UDT Name
---- ------------- ------ ------ -------- -------------- ----------
460 C STRING 2000 H00001 7 xmldata
460 C STRING 30 H00002 12 parse_option
408 CLOB 1024 H00003 8 xmlclob1 XML
4.6.2 Call Level Interface (CLI)
CLI Applications can use the xml, binary, or character data types to work with
XML data from a DB2 database. In CLI API calls, applications can use
application C types of the following:
SQL_C_BINARY
SQL_C_CHAR
SQL_C_WCHAR
SQL_C_DBCHAR
This means that when applications work with XML data types, they can bind
application variables to any of the types just mentioned. The default C type is
SQL_C_BINARY and using this type can avoid code page conversion issues.
The other C types assume the application code page encoding. That is,
SQL_C_BINARY would output in UTF-8, SQL_C_WCHAR in platform-encoding
UTF-16, and SQL_C_CHAR/SQL_C_DBCHAR in the application mixed and
graphic code pages respectively.
On the database end, a column of type xml has a symbolic SQL type of
SQL_XML. The application can use this SQL type when trying to store or retrieve
XML data.
Let us try a simple CLI example. Assuming we have initialized all the necessary
data structures and are connected to the database, we now want to get back the
Search WWH ::




Custom Search