You can
use a UDF to access and read XML documents. For example,
if you want to convert data in an XML document into relational table
format,
you can create a UDF to perform the conversion. Use the New XML Table
Function
wizard to create a DB2® table UDF that takes input from
the XML document
that you specify and returns it in table format for a relational database.
With the wizard, you can also specify that you want to run an XSL
transformation
on the XML document before the data extracts.
Before you begin
Prerequisites: - DB2 UDB
for Linux®, UNIX®,
and Windows®,
Version 8 or later.
Your target database must be enabled
for the DB2 XML Extender. When you enable the DB2 XML
Extender, the XSLTransform UDFs that are provided by the database
engine are
available on the target database to perform the XSL transformation.
To
enable a database for XML Extender, enter dxxadm enable_db sample from
the DB2installdir\sqllib\bin directory
on a command line, where sample is your target
database,
and DB2installdir is the directory in which you
installed DB2.
About this task
To create
a UDF for XML:
- Switch to the Data perspective.
- Click File > New > Other to
open the New
dialog.
- Select Data and
choose User-Defined
Function.
- Click Next. The wizard
opens.
- On the Specify a Project page,
choose to
use a new project or select an existing data development project.
- Click Next. The Name
and Language page opens.
- In
the Language field, select SQL-XML.
- Complete the necessary steps of the wizard.
- Click Finish.
Results
The user-defined function is created and added
to the data development
project that you specified, and the user-defined function is deployed
and
registered on the database server.