Databases Reference
In-Depth Information
All XML APIs supported by Java language, including SAX (Simple API for XML),
DOM (Document Object Model), and StAX (Streaming API for XML) are
discussed in detail in the Java chapter. You can also refer to the DB2 information
center for specific topics regarding application development with Java.
.NET data provider
The DB2 9 .NET interface supports the Microsoft .NET API and ADO.net data
access APIs thoroughly. There is a chapter about application development using
.NET in this topic.
Call Level Interface
The DB2 Call Level Interface (CLI), a superset of ODBC, has been enhanced to
support XML by providing a new SQL type, SQL_XML. Because there is no
native XML type in C, the new SQL type can only be used in CLI/ODBC calls to
mark XML values as XML type. In all other ways, access to serialized XML string
data is identical to using a character array. The advantage is that the DB2 client
and sever know that this is XML data and can avoid unnecessary or unwanted
code page conversions. Example 2-24 shows how to retrieve and update XML
data using the CLI interface.
Example 2-24 Retrieving and updating XML data using CLI
char buf[10240];
integer length;
// retrieve XML
SQLExecute( hStmt, "Select movieDetails from movies where id = '345'",
SQL_NTS );
SQLBindCol( hStmt, 1, SQL_C_BINARY , buf, &length );
SQLFetch( hStmt);
SQLClose( hStmt);
// update as XML
SQLPrepare(hStmt, "update movies set movieDetails = ? where id =
'345'", SQL_NTS );
SQLBindParameter( hStmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY ,
SQL_XML , buf, &length);
SQLExecute( hStmt );
Please note that data is fetched and inserted as SQL_C_BINARY.
Embedded SQL interface
The SQL standard defines new host variable declarations for XML types, and
DB2 is using this in its implementation. Example 2-25 on page 86 shows the
embedded SQL with XML.
Search WWH ::




Custom Search