IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

to extract node name from XML via DB2 dynamic querry


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 2455
Location: Hampshire, UK

PostPosted: Mon Aug 31, 2015 2:04 pm
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: 1281
Location: Belgium

PostPosted: Tue Sep 01, 2015 8:22 pm
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: 1281
Location: Belgium

PostPosted: Tue Sep 01, 2015 8:40 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts optim extract file - SAS DB2 2
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
Search our Forums:

Back to Top