IBM Systems Magazine, Mainframe Edition - November/December 2010 - 45

Code Sample 1
ibm.db2.jcc.DB2Connect ion. registerDB2XmlSchema

hÁ Invoke the following commands
f r om c om m a nd-l i ne pr o c e s s or : –register xmlschema, -add xmlschema document, -complete xmlschema I was happy to learn I didn’t need to write a program to call the stored procedures or invoke the JDBC methods to register the XSD. IBM delivers Data Studio Developer, a no-cost product that can be downloaded and installed on your PC to handle the XSD registration into the XSR for you. Once you’ve registered the XSD you can use the XMLVALIDATE function to verify the document is valid. This function can only be used with the XMLPARSE function. Several different formats can be used for invoking this function, so please read the SQL reference to get more details. In my example, I have the XML document in a host variable and I’ve registered my customer schema as SYSXSR. CUSTSCHEMA
INSERT INTO dsn8910. customer(cid,info) VALUES (:host_cid , (XMLPARSE (DOCUMENT SYSFUN. DSN _ XMLVALIDATE(:host-info , ‘SYSXSR.CUSTSCHEMA’)));

select cx.* from dsn8910.customer c , xmltable(‘$cust/customer’ passing info as “cust” columns cust_id , fi rstname , lastname , street , city , state , country ) as cx order by cx.lastname asc with ur integer varchar(10) varchar(10) varchar(20) varchar(11) varchar(10) varchar(03) path ‘@cid’ path ‘name/fi rstname’ path ‘name/lastname’ path ‘addr/street’ path ‘addr/city’ path ‘addr/state’ path ‘addr/@country’

9L[\YUPUNÃ?43Ã+H[HÃ HZÃHÃ9LSH[PVUHSÃ;HISL
You may need to return the XML data in a relational-table format. The XMLTABLE function will handle this for you. Using the customer XML document, I wanted to return each of the elements as a column in a relational table and sort by last name. Remember in XML the order of a document is the same as the order of the hierarchy. There’s no ORDER BY statement for XML elements. To achieve order, I’m using the XMLTABLE function to return the elements in a table and then use the ORDER BY statement on the returned table (See Code Sample 1, above).

document in XML format. You can also return the XML document in a relational table to allow access to relational operations on the document. This article outlines the strength of COBOL as a development language for the many z/OS developers still supporting COBOL on z/OS applications. Remember COBOL isn’t dead, just as the mainframe isn’t dead. The growth rate in XML on z/OS will only continue to increase, especially with the introduction of native XML support using XML systems services and with the native support in DB2 9 for z/OS with the XML data type. Since the majority of applications developed on z/OS are in COBOL, it makes sense the use of XML with DB2 and COBOL will continue grow as well.

The cost of invoking the parser to validate the XML document is expensive from a CPU standpoint. You should perform validation during development to avoid it in production. Some people ensure they validate in the development stage with triggers; on the development system an insert trigger is defined to invoke the parse validation function. The production system wouldn’t have this trigger defined to avoid the overhead.

;OLÃ-\[\YLÃ>P[OÃ?43Ã+)%Ã HUKÃ*6)63
In this series of articles, I’ve outlined several scenarios using XML with COBOL. If you must parse XML documents stored in a file or you want to generate XML documents from a file, you can do this with native COBOL XML functions. The power of DB2 can be used to store XML documents in native format using the new XML data type. You can return the entire XML document or a portion of the

Troy Coleman is principal product manager for z/OS DB2 Tools at CA Technologies. He has 25 years of experience in IT, specializing in database management.

ibmsystemsmag.com /mainframe NOVEMBER/DECEMBER 2010

45


http://www.ibmsystemsmag.com/mainframe

IBM Systems Magazine, Mainframe Edition - November/December 2010

Table of Contents for the Digital Edition of IBM Systems Magazine, Mainframe Edition - November/December 2010

IBM Systems Magazine, Mainframe Edition - November/December 2010
Contents
On the Web
Editor's Desk: Tradition Takes Planning
Dashboard: Walk While You Work
Data Display: All About Spam
Think Smarter: IBM Offers Smarter Systems for Performance and Scalability
Trends: Rosamilia Oversees Both System z and Power Systems Lines as New GM
Break Through Economics: Dr. Howard Rubin Discusses Mainframe Efficiencies and the zEnterprise System
Streamlining Development: IBM Rational on zEnterprise System Utilizes Multiplatform Development Capabilities
Administrator: The zEnterprise System Changes Firewall Requirements
Technical Corner: z/OS Predictive Failure Analysis Make It Easy to Spot and Fix Soft System Failures
Developer: Native XML Support Strengthens DB2 and COBOL Development
Solutions
Advertisers' Index
Stop Run: Former IBMer Jim Bell Finds Inspiration in Music
IBM Systems Magazine, Mainframe Edition - November/December 2010 - IBM Systems Magazine, Mainframe Edition - November/December 2010
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Cover2
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 1
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Contents
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 3
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 4
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 5
IBM Systems Magazine, Mainframe Edition - November/December 2010 - On the Web
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 7
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 8
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 9
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Editor's Desk: Tradition Takes Planning
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 11
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Dashboard: Walk While You Work
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 13
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Data Display: All About Spam
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 15
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Think Smarter: IBM Offers Smarter Systems for Performance and Scalability
IBM Systems Magazine, Mainframe Edition - November/December 2010 - BMC1
IBM Systems Magazine, Mainframe Edition - November/December 2010 - BMC2
IBM Systems Magazine, Mainframe Edition - November/December 2010 - BMC3
IBM Systems Magazine, Mainframe Edition - November/December 2010 - BMC4
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 17
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 18
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Trends: Rosamilia Oversees Both System z and Power Systems Lines as New GM
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 20
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 21
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 22
IBM Systems Magazine, Mainframe Edition - November/December 2010 - zE1
IBM Systems Magazine, Mainframe Edition - November/December 2010 - zE2
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 23
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 24
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 25
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Break Through Economics: Dr. Howard Rubin Discusses Mainframe Efficiencies and the zEnterprise System
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 27
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 28
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 29
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 30
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 31
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Streamlining Development: IBM Rational on zEnterprise System Utilizes Multiplatform Development Capabilities
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 33
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 34
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 35
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 36
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Administrator: The zEnterprise System Changes Firewall Requirements
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 38
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 39
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Technical Corner: z/OS Predictive Failure Analysis Make It Easy to Spot and Fix Soft System Failures
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 41
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 42
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 43
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Developer: Native XML Support Strengthens DB2 and COBOL Development
IBM Systems Magazine, Mainframe Edition - November/December 2010 - 45
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Solutions
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Advertisers' Index
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Stop Run: Former IBMer Jim Bell Finds Inspiration in Music
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Cover3
IBM Systems Magazine, Mainframe Edition - November/December 2010 - Cover4
IBM Systems Magazine, Mainframe Edition - November/December 2010 - RF1
http://www.ibmsystemsmagmainframedigital.com/mspcomm/ibmsystemsmag/ibmsystems_mainframe_20201112
http://www.ibmsystemsmagmainframedigital.com/mspcomm/ibmsystemsmag/ibmsystems_mainframe_20200910
http://www.ibmsystemsmagmainframedigital.com/mspcomm/ibmsystemsmag/ibmsystems_mainframe_20200708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20200506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20200304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20200102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/2020mfse
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20191112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/relevantz_20190102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/2019mfse
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20181112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/2018mfse
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20171112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170910_v2
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_sesupp
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_linuxsupp
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20161112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/MainframeSecurity
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20151112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150910_se
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150910
http://www.ibmsystemsmagmainframedigital.com/MFSkills
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150506_supp
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20141112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140910_v2
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_gt_201405
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/BigData
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20131112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130910_v2
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20121112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/buyersguide2013
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/ibmsystems_mainframe_2012bg
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20111112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20101112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100910_bg
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20091112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20090910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20090708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20090506
https://www.nxtbook.com/nxtbooks/ibmsystemsmag/mainframe_20090304
https://www.nxtbookmedia.com