General query to recurse through XML nested elements
Hi all,
Using 10g database...and I'm trying to parse XML (stored as clob, no registered schema) that handles nesting and reoccurring of the same element.
i.e.
<Policy ID="1">
<Risk ID="1.1">
<Risk ID="1.1.1">
<Risk ID="1.1.1.1">
</Risk>
</Risk>
</Risk>
<Risk ID="1.2">
</Risk>
<Risk ID="1.3">
<Risk ID="1.3.1">
</Risk>
</Risk>
</Policy>
The "Risk" element can be nested over and over again (and reoccur). Now, I want to combine each child, grandchild, great grandchild..... "Risk" element to the Policy element.
i.e resultset has two columns - policyID, riskID
Next, I'd like to be able to tie each Risk to it's parent Risk
i.e. resultset has two columns - parentRiskID, childRiskID
I know how to handle reoccurring and "known" hierarchies by using the XMLTYPE/PASSING techniques in the FROM clause but I'm struggling with the nesting part because I don't how deep it can go....This would seem to be fairly common in XML.
Any ideas ?
Thanks,
Kevin
Does this help
SQL> var xmltext varchar2(4000)
SQL> --
SQL> begin
2 :xmltext := '<Policy ID="1">
3 <Risk ID="1.1">
4 <Risk ID="1.1.1">
5 <Risk ID="1.1.1.1">
6 </Risk>
7 </Risk>
8 </Risk>
9 <Risk ID="1.2">
10 </Risk>
11 <Risk ID="1.3">
12 <Risk ID="1.3.1">
13 </Risk>
14 </Risk>
15 </Policy>';
16 end;
17 /
PL/SQL procedure successfully completed.
SQL> select POLICY_ID, PARENT_RISK_ID, CHILD_RISK_ID
2 from xmltable
3 (
4 '/Policy'
5 passing xmltype(:xmltext)
6 columns
7 POLICY_ID number(4) path '@ID',
8 RISKS xmltype path '//Risk'
9 ) r,
10 xmltable
11 (
12 '/Risk'
13 passing RISKS
14 columns
15 PARENT_RISK_ID varchar2(40) path '@ID',
16 CHILD_RISK_ID varchar2(40) path 'Risk/@ID'
17 )
18 /
POLICY_ID PARENT_RISK_ID CHILD_RISK_ID
1 1.1 1.1.1
1 1.1.1 1.1.1.1
1 1.1.1.1
1 1.2
1 1.3 1.3.1
1 1.3.1
6 rows selected.
SQL> select POLICY_ID, PARENT_RISK_ID, CHILD_RISK_ID
2 from xmltable
3 (
4 '/Policy'
5 passing xmltype(:xmltext)
6 columns
7 POLICY_ID number(4) path '@ID',
8 RISKS xmltype path '//Risk'
9 ) r,
10 xmltable
11 (
12 '/Risk'
13 passing RISKS
14 columns
15 PARENT_RISK_ID varchar2(40) path '@ID',
16 CHILD_RISK_ID varchar2(40) path 'Risk/@ID'
17 )
18 where CHILD_RISK_ID is not null
19 /
POLICY_ID PARENT_RISK_ID CHILD_RISK_ID
1 1.1 1.1.1
1 1.1.1 1.1.1.1
1 1.3 1.3.1
SQL>
SQL>
Similar Messages
-
HELP.
I am having problems creating this XML schema in CVI.
In particular, the creation of <chassis> and <slot> tags throws an error.
ie.
<chassis1> does not start the container, </chassis1> starts the container and there is no subsequent closing element (ie </chassis1>)
Could one provide example code to resolve my problem?
TIA.
<?xml version="1.0" ?>
<config1>
<chassis1>
<slot1>
<element3>VALUE</element3>
<element4>VALUE</element4>
<element5>VALUE</element5>
</slot1>
<slot2>
<element7>VALUE</element7>
<element8>VALUE</element8>
<element9>VALUE</element9>
</slot2>
</chassis1>
<chassis2>
<slot1>
<element3>VALUE</element3>
<element4>VALUE</element4>
<element5>VALUE</element5>
</slot1>
<slot2>
<element7>VALUE</element7>
<element8>VALUE</element8>
<element9>VALUE</element9>
</slot2>
</chassis2>
</config1>
Solved!
Go to Solution.This is the output as viewed in IE:
<?xml version="1.0" ?>
- <Rack>
- <Chassis>
<Fan1Present>0</Fan1Present>
<Fan2Present>1</Fan2Present>
- <Fuse2>
1
- <Slot0>
<Board2>0</Board2>
</Slot0>
- <Slot1>
<Board2>0</Board2>
</Slot1>
</Fuse2>
</Chassis>
- <Chassis>
<Fan1Present>0</Fan1Present>
<Fan2Present>1</Fan2Present>
- <Fuse2>
1
- <Slot0>
<Board2>0</Board2>
</Slot0>
- <Slot1>
<Board2>0</Board2>
</Slot1>
</Fuse2>
</Chassis>
</Rack> -
Specifying nested element with two different XML Schema
Hello,
I am trying to convert one xml file to another file. I figure data services would be great for this.
My problem relates to how to have a source xml file with a certain xml schema be transformed to one of a different xml schema. I cannot build the nested elements of the target schema.
From the source xml I only need four fields. But they need to be nested three levels in the target xml.
Source
<DRUG_PRODUCT_LST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DRUG_ITEM>
<DRUG_PRODUCT_ID>113083</DRUG_PRODUCT_ID>
<DIN_PDIN>2317559</DIN_PDIN>
<HC_BRAND_NAME>PMS-SILDENAFIL</HC_BRAND_NAME>
<HC_ATC_CODE>G04BE03</HC_ATC_CODE>
</DRUG_ITEM>
<DRUG_PRODUCT_LST
Target
<?xml version="1.0" encoding="ISO-8859-1"?>
<CODES>
<CODE_TYPES>
<CODE_TYPE>
<COD_CODE>113083</COD_CODE>
<COD_DESCR>PMS-SILDENAFIL</COD_DESCR>
<COD_SOURCE>G04BE03</COD_SOURCE>
<COD_NPSA>2317559</COD_NPSA>
</CODE_TYPE>
</CODE_TYPES>
</CODES>
I have tried using an xml pipline to unnest the source, then use a query transform to re-nest for the target. But I do not know how to specify the input schemas.Hello,
I am trying to convert one xml file to another file. I figure data services would be great for this.
My problem relates to how to have a source xml file with a certain xml schema be transformed to one of a different xml schema. I cannot build the nested elements of the target schema.
From the source xml I only need four fields. But they need to be nested three levels in the target xml.
Source
<DRUG_PRODUCT_LST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DRUG_ITEM>
<DRUG_PRODUCT_ID>113083</DRUG_PRODUCT_ID>
<DIN_PDIN>2317559</DIN_PDIN>
<HC_BRAND_NAME>PMS-SILDENAFIL</HC_BRAND_NAME>
<HC_ATC_CODE>G04BE03</HC_ATC_CODE>
</DRUG_ITEM>
<DRUG_PRODUCT_LST
Target
<?xml version="1.0" encoding="ISO-8859-1"?>
<CODES>
<CODE_TYPES>
<CODE_TYPE>
<COD_CODE>113083</COD_CODE>
<COD_DESCR>PMS-SILDENAFIL</COD_DESCR>
<COD_SOURCE>G04BE03</COD_SOURCE>
<COD_NPSA>2317559</COD_NPSA>
</CODE_TYPE>
</CODE_TYPES>
</CODES>
I have tried using an xml pipline to unnest the source, then use a query transform to re-nest for the target. But I do not know how to specify the input schemas. -
Iterate through xml elements vb cs2
Does anyone know how to iterate through xml elements without xml rules (unfortunately I have to do this project with cs2). I've heard it's hard and slow to iterate through each element in cs2.
Here is a script I find useful. It recursively iterates over indesign xml structure and invokes a function on each node.
HTH,
=========================================================
function invokeFunctionOnNode(parentNode, func) {
var pNode = parentNode;
//Call on Parent Node
func(pNode);
var elementCount = 0;
try{
elementCount = pNode.xmlElements.length;
}catch(ex){}
if (elementCount > 0) {
var ctr = 0;
for (var elem = 0 ; elem < elementCount; elem++) {
var currentNode = pNode.xmlElements.item(elem);
func(currentNode);
try {
if (currentNode.xmlElements.length > 0) {
invokeFunctionOnNode(currentNode, func) ;
} catch(ex) {} -
Who to query and join nested elements
I have a table that contains a XMLTYPE Field. How do I query and join nested elements. For example I have a schema that has a PerstrenList element that holds one or more Perstren nodes. The Perstren node will contain a RemarksList node that can contain one or more Remarks nodes. My goal is to query all of the Remarks and join them with the information in it's parent node. Without the parent node information the remark is meaningless. Following is a example document and desire result set. I know how to query the Perstren or the Remarks I just can not figure out how to marry the two. The query should only return the remarks joined with the parent information.
<RasDataSet>
<PerstrenList>
<Perstren>
<TPERS>A</TPERS>
<DEPLY>B</DEPLY>
<STRUC>5</STRUC>
<RemarksList>
<REMARK>
<LABEL>ABC</LABEL>
<GENTEXT>Hello world</GENTEXT>
</REMARK>
<REMARK>
<LABEL>XYZ</LABEL>
<GENTEXT>Oracle XML</GENTEXT>
</REMARK>
<RemarksList>
</Perstren>
<Perstren>
<TPERS>C</TPERS>
<DEPLY>D</DEPLY>
<STRUC>4</STRUC>
<RemarksList>
<REMARK>
<LABEL>EFG</LABEL>
<GENTEXT>Database</GENTEXT>
</REMARK>
<RemarksList>
</Perstren>
<Perstren>
<TPERS>E</TPERS>
<DEPLY>F</DEPLY>
<STRUC>3</STRUC>
</Perstren>
<PerstrenList>
</RasDataSet>
desired Results
TPERS DEPLY LABEL GENTEXT
A B ABC Hello World
A B XYZ Oracle XML
C D EFG Database
select uic,
extractvalue(Column_value,'/Perstren/TPERS') as TPERS,
extractvalue(Column_value,'/Perstren/DEPLY') as DEPLY,
extractvalue(Column_value,'/Perstren/SECUR') as SECUR,
extractvalue(Column_value,'/Perstren/STRUC') as STRUC,
extractvalue(Column_value,'/Perstren/TIME') as TIME,
extractvalue(Column_value,'/Perstren/AUTH') as AUTH,
extractvalue(Column_value,'/Perstren/ASGD') as ASGD,
from test_ref doc,
table(XMLSequence(extract(doc.XML_DOC,'/RasDataSet/PerstrenList/Perstren'))) per
[pre]Sorry my Pre tag was in the wrong place Text reads:
I have a table that contains a XMLTYPE Field. How do I query and join nested elements. For example I have a schema that has a PerstrenList element that holds one or more Perstren nodes. The Perstren node will contain a RemarksList node that can contain one or more Remarks nodes. My goal is to query all of the Remarks and join them with the information in it's parent node. Without the parent node information the remark is meaningless. Following is a example document and desire result set. I know how to query the Perstren or the Remarks I just can not figure out how to marry the two. The query should only return the remarks joined with the parent information.
Sorry my Pre tag was in the wrong place -
Loop through nested elements and insert via PL/SQL
INSERT INTO Orders(id, OrderXML) VALUES
(S_Orders.Nextval,
'<?xml version="1.0" encoding="utf-8" ?>
<Order xmlns="urn:foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:foo foo-1.xsd">
<OrderRef>BBB</OrderRef>
<OrderDate>2005-03-29</OrderDate>
<CustomerID>1051</CustomerID>
<Items>
<Item>
<ProductID>7</ProductID>
<Price>45.6</Price>
<Quantity>2</Quantity>
</Item>
<Item>
<ProductID>19</ProductID>
<Price>73.5</Price>
<Quantity>10</Quantity>
</Item>
</Items>
</Order>'
I some questions regarding index search of nested elements like,Items in the above example.
I would like to know how I can LOOP through the Items like 1..2 LOOP
and insert those elements(item) into one table. Order information should go in to another table.
Can this be done with xpath and PL/SQL.
Regards
UlfHi Marco!
Here's some more information:
CREATE TABLE ITEM (ProductID NUMBER,
Price NUMBER(8,2)
Quantity 10 NUMBER);
CREATE TABLE ORDER (OrderRef VARCHAR2(10),
ORDER_DATE VARCHAR2(10),
CUSTOMERID NUMBER);
The main problem that I have is to create an solution that can be dynamic so that I can have for instance one order and four items in one XML.
The second XML can have one order and 10 items.
First I want to insert the order elements in the order table and then the items records in the item table.
To complicate things futher my real XML have namespaces in the XML, but this I think I can handle.
Summary: So for each order row(element) I want to traverse the Item elements and insert them to the Item table.
Regards
/Ulf -
Cannot transform Java to XML - nested XML elements are empty
Hi,
We're using WLI 9.2.1 and in one of our JPDs we're invoking a transformation control that is supposed to do Java -> XML transform. The XQuery for this gets written and works when tested independently within Workshop.
However, wehn we run the JPD, the transformation is not completely successful. What we find is that attributes values that go into top-level XML elements are populated from the Java object. The nested elements are NOT populated and show up as empty.
Q: Is this s limitation in WLI 9.2?
Googling turned up this reference:
XMLBeans APIs Not Supported for Local Element and Complex Type Variables Produced by XQuery
http://e-docs.bea.com/wli/docs85/relnotes/relnotesLimit.html#1375310
http://edocs.bea.com/wli/docs81/relnotes/relnotesLimit.html#1226313
Q: Is this the problem we are seeing?
Q: If yes, any ideas if this CR138983 fixed in WLI 9.2? (it is open in 8.1, 8.5).
Any pointers will be appreciated.
Thanks.Note: This thread was originally posted in the Swing forum, but moved to this forum for closer topic alignment.
-
Question about xml schemas and the use of unqualified nested elements
Hello,
I have the following schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://xml.netbeans.org/examples/targetNS"
targetNamespace="http://xml.netbeans.org/examples/targetNS"
elementFormDefault="unqualified">
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="age" type="xsd:int"/>
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="name"/>
<xsd:element ref="age"/>
<xsd:element name="height" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>I am just wondering why would someone have a nested element that is unqualified? here the "height" element.
Can anyone explain this to me please?
Thanks in advance,
Julien.
here is an instance xml document
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns='http://xml.netbeans.org/examples/targetNS'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://xml.netbeans.org/examples/targetNS file:/E:/dev/java/XML/WebApplicationXML/web/newXMLSchemaThree.xsd'>
<name>toto</name>
<age>40</age>
<height>180</height>
</person>Don't worry about it.
There are two different styles of schemas. In one style, you define the elements, attributes, etc. at the top, and then use the "ref" form to refer to them. (I call this the "global" style.) The other style is to define elements inline where they are used. ("local" style)
Within some bounds, they work the same and which you use is a choice of you and the tools that generate the schemas.
A warning about the local style. It is possible to define an element in two different locations in the schema that are different. It will get past all schema validation, but it seems wrong to my sense of esthetics. With the global style, this will not happen.
So, how did this happen? Probably one person did the schema when it only had a name and age. Then, someone else added the height element. They either used a different tool, or preferred the other style. I'm aware of no difference in the document you have described between the two styles.
Dave Patterson -
Xml-fragment Issue retrieving Nested element data
Hi,
I've problem retrieving the nested element data from the xml. Using XmlBeans I am getting null when retriving the inner element. I printed the nested element xmlobject it has Xml-Fragment wrapped. I tired using below code it doesn't throw any error but the data is lost
AAAA TempObj=AAAA.getBXXX().getCXXX(0);
//remove xml fragment
XmlOptions xmlOpt = new XmlOptions();
xmlOpt.setSaveOuter();
XmlCursor c= TempObj.newCursor();
c.toFirstChild();
Myclass myclassObj= Myclass.Factory.parse(c.getObject().xmlText(xmlOpt));
log.debug("Records: "+myclassObj .getXXArray().length);
Output:
length should give aleast 1 or more but I am getting 0. That means the xmltext didn't parse properly.
Can anybody suggest what could be the problem.
Thanks in advance.
-Srino answer
-
XML self referred nested element error in Data Services
Hi,
I am using BO Data services for data transfer. I am having an error while transferring data from xml file to database. Here is the scenario:
When i execute the job i get the error that an element "CategoryList" found in xml file but not found in the schema used to build the ETL plan.
i dig into that and found out that "CategoryList" is self referential. For example the CategoryList has a nested element Category, and Category has a nested element CategoryList; which makes CategoryList self referred indirectly. when i don't have this self referential mechanism the data transfer work fine with the same xml and xsd files.
Is there any special way to deal with this?
Thanks
UmerNot sure if you have already got the answer, use "URI" not
"URL". -
Extracting nested element text
Hi everyone,
I have a basic question which has been on my mind for a few days now. I'd be appreciative for any assistance or advice.
I'm aiming to extract info using JDOM from all the children of 'Parent' (please see code below). Getting info/text from 'ChildOne' and 'ChildTwo' is easy, but I am having trouble extracting info out of the nested-element at 'ChildThree'.
I'd be appreciative if anyone can shed light on how to solve such a question: how to not only extract info out of ChildOne, Two but also ChildThree, knowing that ChildThree is nested.
I've playing around with instantiating an element which gets the children of 'ChildThree' and another which gets the elements of 'ChildThree/'FirstChild'... but I think there's an easier way than that!!
I've attached a code-snippet which is resembles my XML file. I'd be very appreciative for any advice.
Thanks,
p
<Root>
<Parent>
<ChildOne>First</ChildOne>
<ChildTwo>Second</ChildTwo>
<ChildThree>
<InnerChild>
<First>Text</First>
<Second>Text</Second>
<Third>Text</Third>
</InnerChild>
</ChildThree>
</Parent>
<Root>I reached a solution to my problem actually.
In case other people have the same problem, this is what I did; source-attached.
I made a behavior called 'displayElements' and it takes a parameter of type Element. I then made it so that for this specific element, I call the '.getChildren()' behavior such that a List is produced. This List was then saved as an Iterator and read-through iteratively.
At the end, I re-called the 'displayElements' method and passed-in the same element because that element MIGHT have inner-elements.
Anyways, enough talk. Here's my code incase other people have the same problem.
public static void displayKids(Element current) {
//Printing the current-element and the corresponding element-text
System.out.println(current.getName() + "\t" + current.getTextTrim());
//Print a row of stars; increases readability
System.out.println("********************************");
//For the specific element, we then call 'getters' which get the
//children for that specific element and save as type 'List'
List<Element> children = current.getChildren();
Iterator iterator = children.iterator();
while (iterator.hasNext()) {
Element child = (Element) iterator.next();
//Recursively calling the function
displayKids(child);
} -
Hi,
I have a general query in OSB. Whenever I try to add any expression through any message processing controls, there are three other tabs, comments, namespaces and variables. Can someone explain what is the use of namespaces and variables. If possible with the help of an example.
Thanks,
BalsHi Bals,
Comments allow the developer to put some lines regarding the functionality of that action/stage. This is same as putting comment in any programming language.
XML Namespaces provide a method to avoid element name conflicts in a XML. To know more please refer -
http://www.w3schools.com/xml/xml_namespaces.asp
Variables section refers to the message context variables like $header, $body, $inbound, $outbound etc. You may refer below link to know more -
http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/context.html
Regards,
Anuj -
Controlling Element Tags using Nested Elements
When I use the below I get:
<?xml version = '1.0'?>
<FSAATLAS>
<STUDENT>
<OBJECT_NAME>ADDRESS_T</OBJECT_NAME>
<INNER_ELEMENT>
<INNER_ELEMENT_ROW num="1">
<DUMMY>X</DUMMY>
</INNER_ELEMENT_ROW>
</INNER_ELEMENT>
</STUDENT>
</FSAATLAS>
How do I get the INNER_ELEMENT_ROW and num="1" from
appearing in the NESTED ELEMENT!!!
Best Regards,
James Colestock
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.xml.sql.query.*;
import org.w3c.dom.*;
import oracle.xml.parser.v2.*;
public class XML {
public XML() {
private static final String QUERY = "select object_name, CURSOR(select dummy as dummy from dual) as INNER_ELEMENT from user_objects";
public static void main(String[] args) throws Throwable {
Connection c = getConnection();
OracleXMLQuery q = new OracleXMLQuery(c,QUERY);
q.setCollIdAttrName("");
q.setCollIdAttr("");
q.setRowIdAttrName("");
q.setRowIdColumn("");
q.setRowsetTag("FSAATLAS");
q.setRowTag("STUDENT");
q.useNullAttributeIndicator(false);
q.useTypeForCollElemTag(false);
String s = q.getXMLString();
System.out.println(s);
q.close();
/*q = new OracleXMLQuery(c,QUERY);
s = q.getXMLMetaData(OracleXMLQuery.SCHEMA,false);
System.out.println(s);
q.close();
q = new OracleXMLQuery(c,QUERY);
Document d = q.getXMLDOM(OracleXMLQuery.SCHEMA);
((XMLDocument)d).print(System.out);
q.close();
q = new OracleXMLQuery(c,QUERY);
s = q.getXMLString(OracleXMLQuery.SCHEMA);
System.out.println(s);*/
public static Connection getConnection() throws SQLException {
String username = " james";
String password = "masterjames";
String thinConn = "jdbc:oracle:thin:@localhost:1526:PORTLAND";
Driver d = new OracleDriver();
return DriverManager.getConnection(thinConn,username,password);
}When I use the below I get:
<?xml version = '1.0'?>
<FSAATLAS>
<STUDENT>
<OBJECT_NAME>ADDRESS_T</OBJECT_NAME>
<INNER_ELEMENT>
<INNER_ELEMENT_ROW num="1">
<DUMMY>X</DUMMY>
</INNER_ELEMENT_ROW>
</INNER_ELEMENT>
</STUDENT>
</FSAATLAS>
How do I get the INNER_ELEMENT_ROW and num="1" from
appearing in the NESTED ELEMENT!!!
Best Regards,
James Colestock
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.xml.sql.query.*;
import org.w3c.dom.*;
import oracle.xml.parser.v2.*;
public class XML {
public XML() {
private static final String QUERY = "select object_name, CURSOR(select dummy as dummy from dual) as INNER_ELEMENT from user_objects";
public static void main(String[] args) throws Throwable {
Connection c = getConnection();
OracleXMLQuery q = new OracleXMLQuery(c,QUERY);
q.setCollIdAttrName("");
q.setCollIdAttr("");
q.setRowIdAttrName("");
q.setRowIdColumn("");
q.setRowsetTag("FSAATLAS");
q.setRowTag("STUDENT");
q.useNullAttributeIndicator(false);
q.useTypeForCollElemTag(false);
String s = q.getXMLString();
System.out.println(s);
q.close();
/*q = new OracleXMLQuery(c,QUERY);
s = q.getXMLMetaData(OracleXMLQuery.SCHEMA,false);
System.out.println(s);
q.close();
q = new OracleXMLQuery(c,QUERY);
Document d = q.getXMLDOM(OracleXMLQuery.SCHEMA);
((XMLDocument)d).print(System.out);
q.close();
q = new OracleXMLQuery(c,QUERY);
s = q.getXMLString(OracleXMLQuery.SCHEMA);
System.out.println(s);*/
public static Connection getConnection() throws SQLException {
String username = " james";
String password = "masterjames";
String thinConn = "jdbc:oracle:thin:@localhost:1526:PORTLAND";
Driver d = new OracleDriver();
return DriverManager.getConnection(thinConn,username,password);
} -
Oracle equivalent of "for xml auto, elements"
Apologies if this is a bit of a "newbie" question.
I have a .NET application that makes extensive use of the SQL Server syntax "for xml auto, elements" to retrieve data as an XML stream and then merge this with XSL to produce reports.
I would like to support both Oracle and SQL Server. Is there a simple way to do this without writing an Oracle specific interface and rewriting all my SQL?Hello.
I am struggling with this, so here are some examples:
MS SQL Server will allow "for XML auto, elements" or "for XML raw" to be added to the end of a SQL statement to return an XML stream instead of a data set. Taking the MS example Northwind database, the query:
"select CompanyName, ContactName from Customers where CustomerId like 'A%' for XML raw"
would return the following stream:
<row CompanyName="Alfreds Futterkiste" ContactName="Maria Anders"/>
<row CompanyName="Ana Trujillo Emparedados y helados" ContactName="Ana Trujillo"/>
<row CompanyName="Antonio Moreno Taquería" ContactName="Antonio Moreno"/>
<row CompanyName="Around the Horn" ContactName="Thomas Hardy"/>
If you were to change the SQL to be:
"select CompanyName, ContactName from Customers where CustomerId like 'A%' for XML auto, elements"
...you would get back:
<Customers><CompanyName>Alfreds Futterkiste</CompanyName><ContactName>Maria Anders</ContactName></Customers><Customers><CompanyName>Ana Trujillo Emparedados y helados</CompanyName><ContactName>Ana Trujillo</ContactName></Customers><Customers><CompanyName>Antonio Moreno Taquería</CompanyName><ContactName>Antonio Moreno</ContactName></Customers><Customers><CompanyName>Around the Horn</CompanyName><ContactName>Thomas Hardy</ContactName></Customers>
I have found this useful when merging with XSL to create reports and/or pages on the fly based on queries. I have recently joined OPN and am looking to migrate my applications to Oracle and this is a key factor for me.
All help gratefully received. -
Price column is blank on GRPO upload through XML
Dear SDK Forum Members,
We are trying to upload GRPO transaction linked to PO through XML, all values import fine but for the Price. The price column is blank.
Need your assistance on this. The following is the sample XML file.
<?xml version="1.0" encoding="UTF-16" ?>
- <BOM>
- <BO>
- <AdmInfo>
<Object>20</Object>
<Version>2</Version>
</AdmInfo>
- <Documents>
- <row>
<DocNum>17</DocNum>
<DocType>dDocument_Items</DocType>
<HandWritten>tNO</HandWritten>
<Printed>tNO</Printed>
<DocDate>May 29 2008 7:29PM</DocDate>
<DocDueDate>May 29 2008 12:00AM</DocDueDate>
<CardCode>V1010</CardCode>
<CardName>Far East Imports</CardName>
<Address>300 Elm Street Suite 300 Los Gatos CA 988778 USA</Address>
<DocCurrency>USD</DocCurrency>
<DocRate>0.000000</DocRate>
<DocTotal />
<Reference1 />
<Comments />
<JournalMemo />
<PaymentGroupCode>2</PaymentGroupCode>
<DocTime />
<SalesPersonCode>2</SalesPersonCode>
<Confirmed>tYES</Confirmed>
<ImportFileNum />
<SummeryType>dNoSummary</SummeryType>
<ContactPersonCode />
<ShowSCN>tNO</ShowSCN>
<Series>13</Series>
<TaxDate />
<PartialSupply>tYES</PartialSupply>
<DocObjectCode>20</DocObjectCode>
<DiscountPercent>0.000000</DiscountPercent>
<RevisionPo>tNO</RevisionPo>
<BlockDunning>tNO</BlockDunning>
<Pick>tNO</Pick>
<PaymentMethod />
<PaymentBlock>tNO</PaymentBlock>
<MaximumCashDiscount>tNO</MaximumCashDiscount>
<WareHouseUpdateType>dwh_Stock</WareHouseUpdateType>
<Rounding>tNO</Rounding>
<DeferredTax>tNO</DeferredTax>
<NumberOfInstallments>1</NumberOfInstallments>
<ApplyTaxOnFirstInstallment>tNO</ApplyTaxOnFirstInstallment>
<DocumentsOwner>3</DocumentsOwner>
<DocumentSubType>bod_None</DocumentSubType>
<Address2 />
<PayToCode />
<UseShpdGoodsAct>tNO</UseShpdGoodsAct>
<IsPayToBank>tNO</IsPayToBank>
<DownPayment>0.000000</DownPayment>
<LanguageCode>3</LanguageCode>
<PickRemark />
<SequenceModel />
<UseCorrectionVATGroup>tNO</UseCorrectionVATGroup>
<VatPercent>0.000000</VatPercent>
</row>
</Documents>
- <Document_Lines>
- <row>
<LineNum>0</LineNum>
<ItemCode>X0004</ItemCode>
<ItemDescription />
<Quantity>10</Quantity>
<ShipDate />
<Price>650.000000</Price>
<PriceAfterVAT>650.000000</PriceAfterVAT>
<Currency>USD</Currency>
<Rate>0.000000</Rate>
<DiscountPercent>0.000000</DiscountPercent>
<VendorNum />
<WarehouseCode>01</WarehouseCode>
<SalesPersonCode>2</SalesPersonCode>
<CommisionPercent />
<TreeType>iNotATree</TreeType>
<AccountCode>_SYS00000000019</AccountCode>
<UseBaseUnits>tNO</UseBaseUnits>
<SupplierCatNum />
<CostingCode />
<ProjectCode />
<BarCode />
<VatGroup />
<Height1>0.000000</Height1>
<Height2>0.000000</Height2>
<Lengh1>0.000000</Lengh1>
<Lengh2>0.000000</Lengh2>
<Weight1>0.000000</Weight1>
<Weight2>0.000000</Weight2>
<Factor1>1.000000</Factor1>
<Factor2>1.000000</Factor2>
<Factor3>1.000000</Factor3>
<Factor4>1.000000</Factor4>
<BaseType>22</BaseType>
<BaseEntry>17</BaseEntry>
<BaseLine>0</BaseLine>
<Volume>0.000000</Volume>
<VolumeUnit />
<Width1>0.000000</Width1>
<Width2>0.000000</Width2>
<Address />
<TaxCode />
<TaxType>tt_Yes</TaxType>
<TaxLiable>tYES</TaxLiable>
<ShippingMethod>3</ShippingMethod>
<CorrectionInvoiceItem>ciis_ShouldBe</CorrectionInvoiceItem>
<CorrInvAmountToStock>0.000000</CorrInvAmountToStock>
<CorrInvAmountToDiffAcct>0.000000</CorrInvAmountToDiffAcct>
<WTLiable>tNO</WTLiable>
<DeferredTax>tNO</DeferredTax>
<NetTaxAmount />
<NetTaxAmountFC />
<LineTotal />
<TaxPercentagePerRow />
<ConsumerSalesForecast>tNO</ConsumerSalesForecast>
<ExciseAmount />
<SWW />
<DistributeExpense>tYES</DistributeExpense>
<ShipToCode />
<RowTotalFC />
<TaxOnly>tNO</TaxOnly>
<UnitPrice>650.000000</UnitPrice>
<LineStatus>bost_Open</LineStatus>
<LineType>dlt_Regular</LineType>
<ChangeAssemlyBoMWarehouse />
</row>
</Document_Lines>
</BO>
</BOM>
Thanks
SudaHi Suda
nice to meet you. thx for your nice email.
what i would try in your xml is to remove linetotal - it's an empty tag.
generally i would try to remove all empty tags.
the next is that you use price, priceafvat, unitprice and they have the same value
but you don't set the taxcode.
maybe you should try your luck with setting only one price tag - start with price or unitprice.
i hope it's a bit helpful - this xml imports are always tricky.
lg David
Maybe you are looking for
-
IE Opening blank white tabs when a link opens a new tab
Internet Explorer will open up and display the first page fine. It's anything that attempts to open a new tab that is the problem. I have two machines one running IE 9 the other IE 11, both Windows 7 Enterprise 32bit. I thought maybe it was a user ac
-
Hi all please help me. I downloaded a ringtone on my iPhone 4S but when tried to download the same ringtone on my ipad iTunes asked me to purchase the same ringtone again. For me I shouldn't be repurchasing the item for which I have already paid, i
-
Costs to be recorded to Internal Order instead of Cost Center
Hi, My client has created a new Personnel Area and has started hiring people for it. They did not create a cost center for this. Meanwhile, if any costs are to be recorded for the employees in this Personnel Area, the client wants them record to an I
-
HP Photosmart R847 Digital Camera
I've been very happy w/ my camera but now it won't come on when I lower the shutter door. I've made sure that it's fully charged, just unplugged it from an overnight charge. I've never had a problem with it until now. BTW, the little blue light is
-
Raising exceptions on hanging or failing updates
I have inherited a storeprocedure of around 400 lines of code wgich contains multiple SQL blocks of a update selection wrapped round a select statement. This store procedure works on dbA but not on dbB on dbA. it just hangs. dbA has more data, so it