Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2033
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 LIST NODE DIRECTORY - db2 clp - tryin... elixir1986 IBM Tools 1 Sat Jul 07, 2018 6:15 pm
No new posts How to extract the difference from Su... pkmurali TSO/ISPF 3 Mon Jul 02, 2018 8:44 pm
This topic is locked: you cannot edit posts or make replies. Need help - DB2 Dynamic SQL Program e... NikhilGuptaGaya DB2 6 Sat Jun 23, 2018 1:58 pm
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us