Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / July 2007

Tip: Looking for answers? Try searching our database.

xml

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stanley Sinclair - 27 Jul 2007 00:51 GMT
I have previously posted in this subject, but this is different, and,
I hope, easier:

Given I have a database in Win V9.1.2.

All data are relational.

Is there a way, either directly through db2, or through MicroSoft ADO
to extract data from various tables into an acceptible XML format.

I see that there are ways to pull out data from an ADO Recordset which
gives the column headers as parameters; and then the data comes out as
what looks like XML records.  But somehow they don't come together as
legitimate XML files.

Does anyone know how to do this?

SS
Dave Hughes - 27 Jul 2007 02:28 GMT
> I have previously posted in this subject, but this is different, and,
> I hope, easier:
[quoted text clipped - 12 lines]
>
> Does anyone know how to do this?

Personally, I'm on DB2 v8 which had limited XML support, but DB2 9
includes a whole bunch [1] of XML stuff which ought to be of use to you
here (including XQuery support).

Still, even in v8 one could probably produce useful XML output
(although I'm not sure what you mean by an "acceptable XML format").
See for example the XMLELEMENT function [2] (which was present in v8,
and is still there in 9). Here's one of the example queries against the
SAMPLE database:

SELECT XMLELEMENT(
    NAME "Department", XMLATTRIBUTES(
      E.WORKDEPT AS "name"
    ),
    XMLAGG(
      XMLELEMENT(
        NAME "emp", E.FIRSTNME
      )
      ORDER BY E.FIRSTNME
    )
  )
  AS "dept_list"
  FROM EMPLOYEE E
  WHERE E.WORKDEPT IN ('A00', 'B01')
  GROUP BY WORKDEPT

Which produces the following output:

<Department name="A00">
<emp>CHRISTINE</emp>
<emp>SEAN</emp>
<emp>VINCENZO</emp>
</Department>
<Department name="B01">
<emp>MICHAEL</emp>
</Department>

Even though this isn't a "proper" XML document (it would need to be
wrapped in a root element and have an XML PI stuck on the front), it's
a good start (adding the necessary tags could be easily done by
UNIONing the query with a couple of VALUES statements, or could be
handled by the application logic).

[1]
http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb
.rn.doc/doc/c0023113.htm

[2]
http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb
.admin.doc/doc/r0022188.htm

HTH,

Dave.

--
2803stan@gmail.com - 27 Jul 2007 23:16 GMT
> > I have previously posted in this subject, but this is different, and,
> > I hope, easier:
[quoted text clipped - 69 lines]
>
> - Show quoted text -
________

Thanks, Dave.

Whole new world!  Using the XML commands is a new language.

Stan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.