How to read the child elements in single query
Hi
How to read the child elements under 'alternateIdentifiers' and 'matchEntityBasic' in a single query followiing xml content.xml content is of xmltype
I/p doc
<UPDATES>
<matchEntity>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<matchEntityId>861873</matchEntityId>
<alternateIdentifiers>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<schemeCode>SMG</schemeCode>
<effectiveDate>2012-01-16</effectiveDate>
</alternateIdentifiers>
<alternateIdentifiers>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<schemeCode>TEBBGL</schemeCode>
<effectiveDate>2012-01-16</effectiveDate>
</alternateIdentifiers>
<matchEntityBasic>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<marketExchangeCode>XASE</marketExchangeCode>
</matchEntityBasic>
</matchEntity>
</UPDATES>
o/p
sourceUpdateId schemeCode effectiveDate marketExchangeCode
SAMSUNG SMG 2012-01-16 XASE
SAMSUNG TEBBGL 2012-01-16
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
i tried the query but not working
SELECT sourceUpdateId ,schemeCode ,effectiveDate ,marketExchangeCode FROM message pl,XMLTABLE ('/UPDATES/matchEntity/alternateIdentifiers'
PASSING pl.messagetext
COLUMNS sourceUpdateId VARCHAR2 (20) PATH sourceUpdateId,
schemeCode VARCHAR2 (20) PATH 'schemeCode',
effectiveDate DATE PATH 'effectiveDate',
marketExchangeCode VARCHAR2 (20) PATH './matchEntityBasic/marketExchangeCode'
) x
iam not retriving marketExchangeCode with the following query
marketExchangeCode VARCHAR2 (20) PATH './matchEntityBasic/marketExchangeCode'
thanks
The problem is that "matchEntityBasic" is not a child of "alternateIdentifiers", so this :
./matchEntityBasic/marketExchangeCodepoints to nothing.
To display both values in the same query, you'll need a two-level approach.
For example :
SQL> SELECT x2.sourceUpdateId
2 , x2.schemeCode
3 , x2.effectiveDate
4 , x1.marketExchangeCode
5 FROM message pl
6 , XMLTable(
7 '/UPDATES/matchEntity'
8 passing pl.messagetext
9 columns marketExchangeCode VARCHAR2(20) PATH 'matchEntityBasic/marketExchangeCode'
10 , alternateIds XMLType PATH 'alternateIdentifiers'
11 ) x1
12 , XMLTable(
13 '/alternateIdentifiers'
14 passing x1.alternateIds
15 columns sourceUpdateId VARCHAR2(20) PATH 'sourceUpdateId'
16 , schemeCode VARCHAR2(20) PATH 'schemeCode'
17 , effectiveDate DATE PATH 'effectiveDate'
18 ) x2
19 ;
SOURCEUPDATEID SCHEMECODE EFFECTIVEDATE MARKETEXCHANGECODE
SAMSUNG SMG 16/01/2012 XASE
SAMSUNG TEBBGL 16/01/2012 XASE
Or the shorter version :
SQL> SELECT x.sourceUpdateId
2 , x.schemeCode
3 , x.effectiveDate
4 , x.marketExchangeCode
5 FROM message pl
6 , XMLTable(
7 'for $i in /UPDATES/matchEntity
8 return
9 for $j in $i/alternateIdentifiers
10 return element r { $j/child::*, $i/matchEntityBasic/marketExchangeCode }'
11 passing pl.messagetext
12 columns sourceUpdateId VARCHAR2(20) PATH 'sourceUpdateId'
13 , schemeCode VARCHAR2(20) PATH 'schemeCode'
14 , effectiveDate DATE PATH 'effectiveDate'
15 , marketExchangeCode VARCHAR2(20) PATH 'marketExchangeCode'
16 ) x
17 ;
SOURCEUPDATEID SCHEMECODE EFFECTIVEDATE MARKETEXCHANGECODE
SAMSUNG SMG 16/01/2012 XASE
SAMSUNG TEBBGL 16/01/2012 XASE
Similar Messages
-
[JS-CS4] - How to read the XML Element and its Attributes
Dear All,
I have the doubt regarding: reading the xmlElement and its attributes.
Here I droping the xml script
//============= Start ======================//
var myDoc = app.activeDocument;
var Fpath = File("../Projects/Entity_map.xml");
if (Fpath.exists)
Fpath.open("r");
var Cont= Fpath.read();
var roots = new XML(Cont);
var myEveryName = new Array();
var myEveryContent = new Array();
var myEveryAttributes = new Array();
traverse(roots);
//$.writeln(myEveryName);
//$.writeln(myEveryContent);
$.writeln(myEveryAttributes.length);
for(var i=0; i<myEveryAttributes.length; i++)
$.writeln(myEveryAttributes[i]);
function traverse(tree) {
myEveryName.push(tree.name());
myEveryContent.push(tree.text());
myEveryAttributes.push(tree.getAttribute);
// you get the contents by using .text() insted of .name()
if(tree.elements().length() > 0) {
for(var i=0; i<tree.elements().length(); i++) {
traverse(tree.elements()[i]);
//============== End =====================//
and the XML Structure is
//===============XML =====================//
<?xml version="1.0" encoding="UTF-8"?>< Entity_Convertion>
< Entitys char="Ç" GID="173"/></
Entity_Convertion>
//===============End ====================//
Here I'm getting the XML Elements and its contents, but not xmlAttributes.
Please any one can help me, then I will appreciate...
Thanks & Regards
T.R.Harihara SudhaNDear All,
I have the doubt regarding: reading the xmlElement and its attributes.
Here I droping the xml script
//============= Start ======================//
var myDoc = app.activeDocument;
var Fpath = File("../Projects/Entity_map.xml");
if (Fpath.exists)
Fpath.open("r");
var Cont= Fpath.read();
var roots = new XML(Cont);
var myEveryName = new Array();
var myEveryContent = new Array();
var myEveryAttributes = new Array();
traverse(roots);
//$.writeln(myEveryName);
//$.writeln(myEveryContent);
$.writeln(myEveryAttributes.length);
for(var i=0; i<myEveryAttributes.length; i++)
$.writeln(myEveryAttributes[i]);
function traverse(tree) {
myEveryName.push(tree.name());
myEveryContent.push(tree.text());
myEveryAttributes.push(tree.getAttribute);
// you get the contents by using .text() insted of .name()
if(tree.elements().length() > 0) {
for(var i=0; i<tree.elements().length(); i++) {
traverse(tree.elements()[i]);
//============== End =====================//
and the XML Structure is
//===============XML =====================//
<?xml version="1.0" encoding="UTF-8"?>< Entity_Convertion>
< Entitys char="Ç" GID="173"/></
Entity_Convertion>
//===============End ====================//
Here I'm getting the XML Elements and its contents, but not xmlAttributes.
Please any one can help me, then I will appreciate...
Thanks & Regards
T.R.Harihara SudhaN -
How to get the child data in MDX query?
I have an MDX query that will return the data for an OLAP report. These report data include the parent_id, child_id and some dimensions data in it. How do I modify the MDX query to have a New member to show a dimension value of the child_id.
The child_is is actually the parent_id on another row. It is the "Pstpd Decision" I want to be included in a new column using the "Appeal Id". Thanks
WITH MEMBER [Measures].[Avg TA Time] AS [Measures].[Turn Around Time]/[Measures].[Number of Request]
SELECT NON EMPTY { [Measures].[Number of Request] } ON COLUMNS,
NON EMPTY { ([Request Date Time].[FY-AP].[Account Period].ALLMEMBERS *
[Request Drugs].[Drug Generic Name].[Drug Generic Name].ALLMEMBERS *
[Dispensary].[Dispensary Hierarchy].[Dispensary].ALLMEMBERS *
[Disease].[Tumour Group Site].[Tumour Group Site].ALLMEMBERS *
[Disease].[Tumour Group Sub Site].[Tumour Group Sub Site].ALLMEMBERS *
[Patient].[Patient Agency ID].[Patient Agency ID].ALLMEMBERS *
[Pstpd Decision].[Decision].[Decision].ALLMEMBERS *
[Request].[Request Id Key].[Request Id Key].ALLMEMBERS *
[Request].[Appeal Id].[Appeal Id].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( { [Appeal Yes No].[Status].&[Yes] } ) ON COLUMNS
FROM ( SELECT ( STRTOSET(@RequestDateTimeFiscalYear, CONSTRAINED) ) ON COLUMNS
FROM [CAP Request])) WHERE ( IIF( STRTOSET(@RequestDateTimeFiscalYear, CONSTRAINED).Count = 1, STRTOSET(@RequestDateTimeFiscalYear, CONSTRAINED), [Request Date Time].[Fiscal Year].currentmember ), [Appeal Yes No].[Status].&[Yes] ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
data.
KahluaI got it to work by adding the child_id's "decison' to the fact table as it is alot easier to get that data using Sql Script while creating the fact table and also there is already a "decsion" dimension setup. In the cube I can select the
parent_id's decision and/or child_id's decision. It is working on the report. Thanks.
Kahlua -
How to read the output of 'tarantella license query' command?
I'm trying to track my license usage (to better determine when to buy new licenses, and to track usage over time).
When I issue the 'tarantella license query command, this is typical of the output I see:
[root@sgdserver ~]# /opt/tarantella/bin/tarantella license query
License usage at: Mon Feb 11 14:03:53 EST 2008
Type In use / Total
Base 6 / 230
UNIX 4 / 230
Mainframe 0 / 230
Windows 0 / 230
AS/400 0 / 230
[root@sgdserver ~]#What is the above saying? Is it saying that I am using 10 licenses out of my 230, or am I just using 6 licenses? In other words, do I add up the numbers or just use the highest one? Or do I just have to worry about the 'Base' license number?
Thanks.The base license is the number of users that are logged into a webtop.
From there you count then connectivity type.
So you have 6 webtop licenses out of 230 consumed and of those 4 users have launched UNIX sessions out of 230 you have licensed.
hope this helps. -
How to read the content in one node of XML in Java? Pls help
My dear brothers,
I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
1. Create a GUI form which gives the ability for user to choose a XML file (ok)
2. Load XML and return the file (ok)
3. Read the file from node to node to create the node in Tree View (?!)
Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
Hoang Yen BinhI hope this one helps you.
<ABC Type="ProductBased" ProdName="One" Location="India">
<CEO>Raj</CEO>
<Finance>Vikram</Finance>
<HR>Karthik</HR>
<Technical>Satish</Technical>
</ABC>
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Attr;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
public class XmlReading {
Document doc;
Element element;
public static void main(String[] args) throws Exception{
XmlReading xr = new XmlReading();
xr.getXmlParser(args);
public void getXmlParser(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
if(args.length != 1) {
System.err.println("Argument Required");
try {
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(new File(args[0]));
}catch(ParserConfigurationException e1) {
}catch(SAXException e2) {
}catch(IOException e3) {
getAttributes();
public void getAttributes() {
// Retrive the entire Document from the Dom Tree
element = doc.getDocumentElement();
// System.out.println(element);
NamedNodeMap attrs = element.getAttributes();
// Get number of attributes in the element
int numAttrs = attrs.getLength();
// Process each attribute
for (int i=0; i<numAttrs; i++) {
Node node = attrs.item(i);
// Get attribute name and value
String attrName = node.getNodeName();
String attrValue = node.getNodeValue();
System.out.println(attrName + ": " + attrValue);
String s1 = element.getTagName();
System.out.println(s1);
// To get all the elements in a DOM Tree
NodeList nl1 = element.getElementsByTagName("*");
int i2 = nl1.getLength();
System.out.println(i2);
for(int i=0; i<i2; i++) {
System.out.println(nl1.item(i) + "\n");
} -
How to read the complete path in file upload UI
Hi,
I want to know how to read the complete path in file upload UI in java web dynpro.
I have created 1 file upload UI and than when i do browse and select some file say small.jpg from my local PC, desktop , its path is coming in file upload UI like E:\small.jpg,
I want to know how to get this path in java webdynpro code.
please let me know..Hi Satyam,
In webdynpro java, first file stores in server location then it reads from server.
Create a button with upload and write this code OnAction
Resource is the attribute name in context of type com.sap.ide.webdynpro.uielementdefinitions.Resource, this attribute is for Resource property for Upload UI Element.
Then in OnAction of button
InputStream text = null;
int temp=0;
try{
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
String path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path);
}catch(Exception e){
e.printStackTrace();
//@@end
Regards,
Pradeep
Edited by: pradeep_546 on May 11, 2011 12:22 PM -
How to delete the last element of a collection without iterating it?
how to delete the last element of a collection without iterating it?
To add to jverd's reply, even if you could determine the last element, in some collections it is not guaranteed to always be the same.
From HashSet:
It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. -
How to read the current selection in a table.
Hello Experts,
I've this issue with the web dynpro. I have a Adaptive Webservice Model in web dynpro. And I have three tables in the UI. When a row is selected in the first table, the second table is populated with the appropriate data (using a method in the web service.) the same applies to the third table, when the a row is selected in the second table, the third table has to be populated with the appropriate data. The methods in the web service are all working fine. However, in web dynpro, I am not able to figure out on how I read the selected row in a table. Any information on how to resolve this would be really really helpful.
<
wdContext.currentGetMailElement().setProfileID("-Should be read from the selected row in the table.");
wdThis.wdGetMailControllerController().executeGetMail();
>
regards,
Sam.Hi Samuel,
I didnt clearly understood your problem. When you are selecting a particular row in a table you are executing a web service named Get Mail. Are you passing any input parameter(any selected row data) while executing a web service. And when you get the response node where you have a attribute in the node getmail. Am I right.
If this is the case, then first check if the GetMail node is present or not by comparing it will null or checking its size. If the node is null then you will not get attribute as the element itself is null as nothing is retrieved in response. And if the node is not null then the element at 0th position is selected by default. you can retreieve the attribute by directly using the following code
if(wdContext.nodeGetMail() !=null)
String profileId= wdContext.currentGetMailElement().getProfileID();
Check if this works for you.
Regards,
Ardhendu Sarkar -
How to get the text elements for a particular program
Hi All,
I want to get the all text elements , selection texts for a particular program...How to get.
I have used one FM READ_TEXTELEMENT_FROM_REPORT , but not much useful..
please help me..
Regards,
rajHi..
You may use this statement to read the text elements:
DATA: i_reptx TYPE STANDARD TABLE OF textpool WITH HEADER LINE.
READ TEXTPOOL (reports) INTO i_reptx. " reports is the report name.
Best Regards,
Pradeep. -
Reading the next element with sam name
Hi,
i have xml file which looks like
<Response>
<params>
<param>
<value><array><data><value><string>ok</string></value>
<value><string>41408241257406373</string></value>
</data></array></value>
</param>
</params>
</Response>
I need the value of element string which i am reading now using
<string>ok</string>
using
xmldom.getfirstchild
But problem is how to read the next one as its tag name is also the same?
<string>41408241257406373</string>
thanks,
7Zsorry if I was not clear.
I call soap request and get a XML response
<Response>
<params>
<param>
<value><array><data><value>
<string>ok</string>
</value>
<value>
<string>41408241257406373</string>
</value>
</data></array></value>
</param>
</params>
</Response>
I have already funtion by using dom that read the first tag and work fine.
But for this XML
<string>ok</string> ----string tag
<string>41408241257406373</string> -----string
it is
function gettvalue(p_node dbms_xmldom.domdocument, p_tag in varchar2)
return varchar2
is
t_node dbms_xmldom.domnode;
t_child_node dbms_xmldom.domnode;
begin
t_node := xmldom.item (xmldom.getelementsbytagname(p_node, p_tag), 0);
if xmldom.isnull(t_node)
then
return null;
end if;
t_child_node := xmldom.getfirstchild (t_node);
if xmldom.isnull(t_child_node)
then
return null;
else
return xmldom.getnodevalue(t_child_node);
end if;
end;
it is not reading the second element.
thanks for help.
odie_63 -
How to find the WBS element for the payment document?
Dear All,
How to find the WBS element in the payment document?...I know in payment doc there will not be any WBS but is there any option where I can find in any of the Tables.
I am in the process of developing a Z report where i need to fetch the payment documents based on WBS. Can any one please help me on this.Hi Ram,
As you are not giving any input of WBS at the time of payment you cannot fetch this directly. But to know the WBS for the reporting purpose on which WBS the payment has been made, you can develop a Z-Report. The WBS elements of clearing documents against the payment entry can be fetched out.
In this report if there is a single payment against many invoices also possible with different invoice and WBS elements to be displayed on the Z-Report
Regards
Divya S -
Dynamically rename the root node of XML based on the child elements
Hi Gurus,
Is there any way to rename the root node of the resultant XML after a mapping based on the child elements.
For ex:
consider the following resultant XML after mapping
<result>
<element1> </element1>
<result>
if the element1 is <type> then the output should be
<category>
<type> </type>
</category>
elseif the element1 is <character> then the output should be
<property>
<character> </character>
</property>
Let me know how to do this, either in XSLT or in Graphical mapping.
Thanks,
PrabuHi, Prabu:
In this case, I am suggest you have Src and Tar Message.
I am suggesting you create another type of message using key / value pair as I suggested, e.g. called Mid Message.
My solution for you is to have two message mappings:
1. Src -> Mid
2. Mid -> Tar.
In first mapping, you have no control of the structure, but you can map it to Mid structure:
e.g.
if Type node Exist, then map 'Type' to Key, as Key/Value can be creatd under a parent node with 0:1 Occurrence.
saying item.
in this case, a new item created.
If you think of this way, any xml file can be represted in this way:
<Employee>
<Fname>David</Fname>
<Lname>Miller</Lname>
</Employee>
<Employee>
<Fname>Steve</Fname>
<Lname>Mai</Lname>
</Employee>
Can be interpretd as this way:
<Employee>
<Element>
<key>Fname</Key>
<value>David</Value>
</Element>
<Element>
<key>Lname</Key>
<value>Miller</Value>
</Element>
</Employee>
<Employee>
<Element>
<key>Fname</Key>
<value>Steve</Value>
</Element>
<Element>
<key>Lname</Key>
<value>Mai</Value>
</Element>
</Employee>
Now you should understand what I mean.
In your case target structure have to desgined as following way:
You need to put Category and Property together with their sub-structure in parallel, make occurence to 0:1
In your second mapping, you can check the key value is "Type" or "Character", based on which one is true,
you create corresponding structure: either Categary or Property.
Regards
Liang
Edited by: Liang Ji on Oct 22, 2010 8:31 PM
Edited by: Liang Ji on Oct 22, 2010 8:35 PM -
How can I get the same result using single query?
There are 3 tables
1) tool_desc -
a master table for storing tool records,
columns tool_no, tool_chg,
# of records = 1.5 Millon
2) step_desc -
a master table for storing plan wise step records,
columns plan_id, step_key,
# of records = 3700 Million
3) step_tool - a transaction table storing tools to the steps,
columns plan_id, step_key, tool_no, tool_chg
For each step in the step_desc table, I need to randomly fetch 1 to 50 tools from tool_desc and insert them into step_tool table.
Using PL/SQL block, it is like the following -
begin
for x in (select plan_id, step_key from step_desc) loop
insert into step_tool(
plan_id,
step_key,
tool_no,
tool_chg)
select
plan_id,
x.step_key,
tool_no,
tool_chg
from
tool sample(0.1)
where
rownum <= trunc(dbms_random.value(1,51))
commit;
end loop;
end;
I need to do the same using a single query so that I can use the CTAS (create table as select) statement and load the data as a bulk.
Can I do that?If they have parent child releation, you can use connect by prior clause,
-
How to read the data in excel sheet
Dear sir,
How to read the data in excel sheet when i recieve a data serial communication... ie i have store a data in excel such that
Cell A Cell B
A Apple
B Ball
C Cat
D Doll
when i recieve A from serial communication i have to display Apple, and when i recieve B i have to display Ball and so on..Hi,
I would recommend you to have a look at the VI attached. It makes use of a VI named 'Read from Spreadsheet' to read the row and column data from the tab delimited excel file. The read data is then searched for the Alphabet specified and finally returns you the corresponding string. The test file used to validate the operation of the VI is also attached.
Trust this would help you solve the issue.
Regards,
Sagar G Yadav | Application Engineer | National Instruments
Attachments:
read_from_excel.vi 10 KB
Book1.txt 1 KB -
How to read the file from a folder.
Hi All,
How to read the file from a folder or directory from the non sap server / remote server.
Regards
Sathisopen dataset filename for input in text mode
encoding default.
filename is character type variable with the destination filename.
Edited by: Jino Augustine on Apr 19, 2010 1:31 PM
Maybe you are looking for
-
I hear my 2010 17" Macbook Pro starting but no picture on screen. HELP!
I have a 2010 17" macbook pro with no upgrades besides software updates, instillation and small normal things like those. I left it on one night when i fell asleep listening to pandora (internet radio). The next morning i connected the charger to it
-
How can you prevent the mac book pro from unexpectedly shutting off and beeping three times repeatedly?
-
I burned a test DVD of my movie exporting to compressor then importing into DVD Studio. I am aware that a DVD played on flat screen TV is going to cut off about 10-20% of the movie around the borders, hence the title safe overlays when editing. Unfor
-
Need to create view ( Urgent )
Hi All, I have one requirement to create a view .Presently we are using a packaged procedure(view_test_123_pkg) to extract part numbers to write to a file using utl_file package. Now the requirement is to create a single column view to extract part n
-
OK, so yesterday I was given the Blackberry Curve 9300. It was all fine, I could acess BBM, Facebook, and I could put music on it and play it. But this morning, I decided to put a few more songs on my Blackberry from a CD I also got for Christmas. Bu