Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Learn to Use XML with DB2

If you need to store XML data in DB2, translate XML to relational data, or shred relational data into XML, the XML Extender for DB2 is an essential utility. But it's not always straightforward. Find out what it can do and what problems to expect.


advertisement
y employer has just spun off our product testing facility into an independent organization, able to seek other clients. They will have their own, independent data systems but background data must be sent and test results must be retrieved to our core system with minimal effort.

XML is a logical choice for the exchange and is supported by the group developing for the new company.

Now I need to export data and accept it back in XML; I don't have full control over the data formats, and I have precious little time.



XML Extender to the rescue!


I need to exchange data between an existing DB2 database and another party, using XML, with minimal development.


Use DB2's XML Extender to translate between XML and relational data in DB2.

IBM delivers DB2's XML support in the form of an "Extender"—a kind of privileged add-on that integrates closely with the core database. The Extender includes indexing capabilities and adds new data types and functions.

XML Extender for DB2 v7.2 is available for download. DB2 v8.1 includes the XML Extender in the regular installation kits, and it installs simply as an optional component. (See the "Getting Started" sidebar for more information on installing the XML Extender.)

What You Need
DB2 v8.1, or v7.2 with XML Extender. Based on Window 2000 install with DB2 v8.1.

There are tutorials for using the Extender in online documentation and on Web sites such as IBM's Developer Domain. I won't attempt to reproduce or better them, but I can give you a quick rundown on what to expect from DB2 with XML.

Before you begin working on any DB2/XML solution, you need to figure out what your real requirements are.

Table 1: XML vs. Relational Options in DB2

Requirement

Solutions

Translate relational data to XML

You can:

  • Use simple functions
  • Use a "SQL Collection" to map a query to an XML document structure
  • Use an "RDB Node Collection" to map a number of tables to an XML document structure (this also allows XML import)
  • Alternately, you could ignore DB2's capability and use Visual Basic or VB Script (see the article, "Generating XML from ADO Recordsets").

"Shred" (translate) XML to relational data



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date