Unix Technical Forum

Help extracting XML from db gives extra element/tag

This is a discussion on Help extracting XML from db gives extra element/tag within the Oracle Database forums, part of the Database Server Software category; --> Thank you for taking the time to read my post. I am new to oracle and put in a ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 02:21 PM
tb01923@gmail.com
 
Posts: n/a
Default Help extracting XML from db gives extra element/tag

Thank you for taking the time to read my post. I am new to oracle and
put in a high pressure situation where I need to extract XML from a
relational DB. I was able to get all the info I need in the right
format, with one exception an extra tag! How do I get rid of the
XMLTYPE tag that is created around the client tag (which is generated
from the XMLSEQUENCE function).

Thank you in advance, the code and the output are posted below.

The select statement is as follows:

SELECT
(
XMLELEMENT
(
"items"
,XMLCONCAT
(
XMLSEQUENCE
(
CURSOR
(
SELECT
changedFunds.cusip as "cusip"
,changedFunds.tradingsymbol as "trading-symbol"
,changedFunds.registered as "registered"
,XMLSEQUENCE
(
CURSOR
(
/*clients from legacy system 1 */
SELECT
freq.clientId as "client-id"
,freq.frequency as "frequency"
FROM
FactSheetFrequency freq NATURAL JOIN Fund_Lineup
clientFunds
WHERE
freq.clientId = 1
AND clientFunds.cusip = changedFunds.cusip
UNION
/*clients from legacy system 2 */
SELECT
freq.clientId as "client-id"
,freq.frequency as "frequency"
FROM
FactSheetFrequency freq NATURAL JOIN
Fund_Lineup_Lincoln clientFunds
WHERE
freq.clientId = 2
AND changedFunds.cusip = clientFunds.cusip
)
,XMLFORMAT('client')
) as "clients"
FROM
factsheetqueue changedFunds
)
,XMLFORMAT('item')
)
)
)
)
as
res
FROM
dual



And generates the foloowing XML


<items>
<item>
<cusip>1</cusip>
<trading-symbol>funda</trading-symbol>
<registered>1</registered>
<clients>
<XMLTYPE>
<client>
<client-id>1</client-id>
<frequency>weekly</frequency>
</client>
</XMLTYPE>
<XMLTYPE>
<client>
<client-id>2</client-id>
<frequency>quarterly</frequency>
</client>
</XMLTYPE>
</clients>
</item>
<item>
<cusip>2</cusip>
<trading-symbol>fundb</trading-symbol>
<registered>0</registered>
<clients>
<XMLTYPE>
<client>
<client-id>2</client-id>
<frequency>quarterly</frequency>
</client>
</XMLTYPE>
</clients>
</item>
<item>
<cusip>3</cusip>
<trading-symbol>fundc</trading-symbol>
<registered>0</registered>
<clients>
<XMLTYPE>
<client>
<client-id>1</client-id>
<frequency>weekly</frequency>
</client>
</XMLTYPE>
</clients>
</item>
</items>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:15 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com