Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

to extract node name from XML via DB2 dynamic querry

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Mon Aug 31, 2015 1:58 pm    Post subject: to extract node name from XML via DB2 dynamic querry
Reply with quote

Hi all,

I have a requirement to extract node name from XML via db2 dynamic query.I used the below code but it is not working :

select xmlcast(xmlquery('name(/*)' PASSING SRC_SYS_DATA_XML) as CHAR(40))
from F5980DBA.T_XML_STOR
where XML_STOR_ID = 21


XML payload:
<ns5:publishPlanResponse xmlns:ct="urn:complextypes.groupvoluntaryworkbenefits.product.ins.us.metlife.com" xmlns:cthdr="urn:complex.groupadmin.product.ins.us.metlife.com" xmlns:ns5="urn:metlife.com/us/ins/product/groupvoluntaryworkbenefits/PublishPlan_SyncServiceWSV1" xmlns:usbhdr="urn:messages.america.globaltechnology.metlife.com">
<cthdr:Header>
<usbhdr:MinorHeaderVersionNumber>0</usbhdr:MinorHeaderVersionNumber>
<usbhdr:MajorHeaderVersionNumber>1</usbhdr:MajorHeaderVersionNumber>
<usbhdr:UserID>
<usbhdr:UserID>tmahendran</usbhdr:UserID>
</usbhdr:UserID>
<usbhdr:MessageData>
<usbhdr:MessageCorrelation>
<usbhdr:TransactionCorrelationID>Q/4kQdOVn/tlZTVkZjEwOS0wNGRkLTQ3cmMAAAAA</usbhdr:TransactionCorrelationID>
</usbhdr:MessageCorrelation
(something like this)
I need to extract publishPlanResponse from this.
Can anyone help me with the correct code??
Thanks in advance
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Mon Aug 31, 2015 2:04 pm    Post subject:
Reply with quote

What "is not working" about this? Sample input, correct and incorrect sample output could illustrate the problem better.

(After so many years in the forum you should be able to use the code tags by now.)
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Sep 01, 2015 8:22 pm    Post subject:
Reply with quote

Quote:
An XQuery expression starting with token "/" cannot be processed because the focus component of the dynamic context has not been assigned.

meaning you haven't assigned on what the query should be run :

Code:
select xmlcast(xmlquery('$doc/name(/*)' PASSING SRC_SYS_DATA_XML as "doc") as CHAR(40))
from F5980DBA.T_XML_STOR
where XML_STOR_ID = 21

or
Code:
select xmlcast(xmlquery('$SRC_SYS_DATA_XML/name(/*)' PASSING SRC_SYS_DATA_XML as "SRC_SYS_DATA_XML ") as CHAR(40))
from F5980DBA.T_XML_STOR
where XML_STOR_ID = 21
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Sep 01, 2015 8:40 pm    Post subject:
Reply with quote

this should also work :
Code:
Select MyTable.MyRootName
from F5980DBA.T_XML_STOR
     , XMLTABLE('$doc' passing SRC_SYS_DATA_XML as "doc"
      COLUMNS
        "MyRootName" char(40) PATH 'name(/*)') as MyTable
where XML_STOR_ID = 21
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Need to create file with Dynamic Name... kapil27 JCL & VSAM 4 Wed May 25, 2016 9:45 am
No new posts Validating TSO node id in Job venkaraj JCL & VSAM 16 Thu May 05, 2016 4:41 pm
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us