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: 1788
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: 1281
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: 1281
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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm


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