Databases Reference
In-Depth Information
Example 2-25 Using XML in embedded SQL
EXEC SQL BEGIN DECLARE;
SQL TYPE IS XML AS CLOB( 10K ) xmlBuf;
SQL TYPE IS CLOB( 10K ) clobBuf;
EXEC SQL END DECLARE SECTION;
// as XML
EXEC SQL SELECT movieDetails INTO :xmlBuf from movies where id = '345';
EXEC SQL UPDATE movies SET movieDetails = :xmlBuf where id = '345';
// as CLOB
EXEC SQL SELECT XMLSerialize( movieDetails ) INTO :clobBuf from movies
where id = '345';
EXEC SQL UPDATE movies SET movieDetails = XMLParse(:clobBuf) where id =
'345';
2.2.12 Utilities and XML support
In DB2 9, DB2 utilities and commands are modified for XML support.
XML import and export
IMPORT and EXPORT commands are updated for XML options. The IMPORT
and EXPORT command treats the XML value similar to the LOBs. Equivalent to
the LOB's options LOBFILE, LOBS TO and LOBS FROM, XMLFILE, XML TO
and XML FROM options are added for the XML values. The only difference
between the LOBs and XML export is that unlike LOBS, an inline XML value in
the exported data file is not possible. So the XML values are exported to the
separate files always. Similar to LOB location specifier (LLS) for LOB data, an
XML data specifier (XDS) is introduced to define the XML value in data files. The
attributes of the XDS are FIL, OFF, LEN, and SCH, which we explain as follows:
FIL
This attribute gives the file name where the XML values are exported.
OFF
This attribute specifies the offset of the XML value in the file in case XML
values are concatenated in a single file.
LEN
This attribute specifies the length of the XML value.
SCH
For IMPORT, this attribute gives the XML schema relational name, which is
used to validate the XML schema while importing the data to the table. To
Search WWH ::




Custom Search