Need output of a query in given xml format.
I have a table as
create table t_cases (case_id number, pros_seq number, case_lname varchar2(100),
day_phone number, night_phone number, intl_phone number);
where case_id and pros_seq is the compound primary key.
The insert script to insert the data in the table is
insert into t_cases values(1, 1, 'test', 12, 23, 34);
insert into t_cases values(1, 2, 'test', 56, 67, 78);
commit;
Now from this table I need to query and fetch the data in the following xml format.
<case REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<caseid>1</caseid>
<prosseq>1</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>12</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>23</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>34</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
<rowdata REPEATINGINDEX="2">
<caseid>1</caseid>
<prosseq>2</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>56</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>67</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>78</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
</case>
Please let me know how to do this.
Like this...
select XMLELEMENT( "case", XMLATTRIBUTES ('PageList' as "RepeatingType")
,xmlagg(
xmlelement("rowdata", xmlattributes(pros_seq as "RepeatingIndex")
,xmlelement("caseid", case_id)
,xmlelement("prosseq", pros_seq)
,xmlelement("PhoneNumbers", xmlattributes('PageList' as "RepeatingType")
,xmlelement("rowdata", xmlattributes(1 as "RepeatingIndex")
,xmlelement("CountryCode", day_phone)
,xmlelement("Type", 'Day')
,xmlelement("rowdata", xmlattributes(2 as "RepeatingIndex")
,xmlelement("CountryCode", night_phone)
,xmlelement("Type", 'Night')
,xmlelement("rowdata", xmlattributes(3 as "RepeatingIndex")
,xmlelement("CountryCode", intl_phone)
,xmlelement("Type", 'International')
as x
from t_cases
Similar Messages
-
Need the output of a query in given XML format
I have a table as
create table t_cases (case_id number, pros_seq number, case_lname varchar2(100),
day_phone number, night_phone number, intl_phone number);
where case_id and pros_seq is the compound primary key.
The insert script to insert the data in the table is
insert into t_cases values(1, 1, 'test', 12, 23, 34);
insert into t_cases values(1, 2, 'test', 56, 67, 78);
commit;
Now from this table I need to query and fetch the data in the following xml format.
<case REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<caseid>1</caseid>
<prosseq>1</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>12</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>23</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>34</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
<rowdata REPEATINGINDEX="2">
<caseid>1</caseid>
<prosseq>2</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>56</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>67</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>78</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
</case>
Please let me know how to do this.Like this...
select XMLELEMENT( "case", XMLATTRIBUTES ('PageList' as "RepeatingType")
,xmlagg(
xmlelement("rowdata", xmlattributes(pros_seq as "RepeatingIndex")
,xmlelement("caseid", case_id)
,xmlelement("prosseq", pros_seq)
,xmlelement("PhoneNumbers", xmlattributes('PageList' as "RepeatingType")
,xmlelement("rowdata", xmlattributes(1 as "RepeatingIndex")
,xmlelement("CountryCode", day_phone)
,xmlelement("Type", 'Day')
,xmlelement("rowdata", xmlattributes(2 as "RepeatingIndex")
,xmlelement("CountryCode", night_phone)
,xmlelement("Type", 'Night')
,xmlelement("rowdata", xmlattributes(3 as "RepeatingIndex")
,xmlelement("CountryCode", intl_phone)
,xmlelement("Type", 'International')
as x
from t_cases -
Output query result in XML format
folks:
could anybody provide more information
about how to generate query result in
xml format? looks like DBXML is for demo only
and i have heard that PLSQL XML parser is the way to go; so far i have not found
a sample yet on how to actually
do the XML generation; if you know more
about it, please let me know; thanks in
advance.
BillHere are some sample apps that might interest you:
[list]
[*][url [URL=http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The]http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The XML Flight Finder
[*][url [URL=http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B]http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B with XML
[list]
Enjoy,
-rh -
!!!URGENT!!!! -- Output Changes supplier details in an XML format
Hi all,
My platform is 11i Apps and 8i Database
I am really new to XML, however I have a requirment to achieve the following:
For updated or new suppliers, I need to output the new information in an XML format.
But, I am not sure how best to achieve this... can anyone offer me a some rough guidline where to begin.
Many thanks in advance
CheersPlease refer to the XSU document at:
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/xsu/xsu_userguide.html -
Returning query results in XML format
Besides using custom tag library, does anyone know any methods or techniques that i can retrive the query results from database in XML format. for example, i have a table named student in database like this:
StudentNo Name Gender Degree
123 Tony male B.Comp.Sci.
456 Tom male B.Fiance
343 Mary female B.Accountingso, if i have query select * from table student, i would get someting like the following:
<row>
<studentNo>123</studentNo>
<name>Tony</name>
<Gender>male</Gender>
<Degree>B.Comp.Sci</Degree>
</row>
<row>
<studentNo>456</studentNo>
<name>Tom</name>
<Gender>male</Gender>
<Degree>B.Finace</Degree>
</row>
The reason i am asking for this is i need query results returned in XML format, so i can wrap XSLT tag around, and apply for HTML, WML, and XHTML template resprectively so i can display them on different terminals. any help is appreciated.I have this method in a ResultSetMapper class:
* Return result sets as an XML stream, with root tag named
* "results", one "result" tag per row, and "result" child tag
* names equal to the column name
* @param query result set
* @param list of column names to include in the result map
* @throws SQLException if the query fails
* @throws JDOMException if the XML stream creation fails
public static final Document toJDOM(ResultSet rs, List wantedColumnNames)
throws SQLException, JDOMException
Element rows = new Element("results");
int numWantedColumns = wantedColumnNames.size();
while (rs.next())
Element row = new Element("result");
for (int i = 0; i < numWantedColumns; ++i)
String columnName = (String)wantedColumnNames.get(i);
Object value = rs.getObject(columnName);
row.addContent(new Element(columnName).setText(value.toString()));
rows.addContent(row);
return new Document(rows);
}It uses JDOM from www.jdom.org. - MOD -
Saving the query result in XML format
Hi All,
I have a requirement to save the result of a query in XML format on the application server. Can we do this?
Best Rgds,
James.You can explore the possibility of the execution of query with XMLA:
Official documentation
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1d71d190-0201-0010-239a-8b96516bf372
and a good Blog
/people/prakash.darji/blog/2006/09/04/work-with-xmla-web-service-for-bi-data-in-external-applications
The result will be an SOAP message (XML) but also the request could be a SOAP message you can investigate if simulate the request by BW client or server.
Regards,
Sergio -
WITH rcv_transactions
AS (SELECT 1001 TRANSACTIONS_ID,
-1 PARENT_TRANSACTION_ID,
'RECEIVE' TRANSACTION_TYPE,
NULL LPN_ID,
'LPN01' TRANSFER_LPN_ID
FROM dual
UNION ALL
SELECT 1002,
1001,
'DELIVER',
'LPN01',
'LPN01'
FROM dual
UNION ALL
SELECT 1003,
-1,
'RECEIVE',
NULL,
'LPN01'
FROM dual)
SELECT *
FROM rcv_transactions;
My output for the above query is
transactions_id parent_transaction_id transaction_type lpn_id transfer_lpn_id
1001 -1 receive lpn01
1002 1001 deliver lpn01 lpn01
1003 -1 receive lpn01
I want the output as below:
TRANSACTIONS_ID, PARENT_TRANSACTION_ID, TRANSACTION_TYPE, LPN_ID, TRANSFER_LPN_ID,
1003 -1 RECEIVE LPN01
i.e., I want the transactions id which are only 'receive' and not 'deliver' for the particular transfer_lpn_id
in the above scenario 1001 is received and delivered in 1002.
But 1003 is only received. so I need the output of 1003WITH rcv_transactions AS (SELECT 1001 TRANSACTIONS_ID,
-1 PARENT_TRANSACTION_ID,
'RECEIVE' TRANSACTION_TYPE,
NULL LPN_ID,
'LPN01' TRANSFER_LPN_ID
FROM DUAL
UNION ALL
SELECT 1002,
1001,
'DELIVER',
'LPN01',
'LPN01'
FROM DUAL
UNION ALL
SELECT 1003,
-1,
'RECEIVE',
NULL,
'LPN01'
FROM DUAL)
SELECT *
FROM rcv_transactions rcv_out
WHERE rcv_out.transaction_type = 'RECEIVE'
AND NOT EXISTS
(SELECT 1
FROM rcv_transactions
WHERE parent_transaction_id = rcv_out.TRANSACTIONS_ID) -
Internal table data download to XML format
Hello All,
I have devloped one OOPS ALV report in that our requirement is on "SAVE" button the data of the report has to be downloaded in given XML format.Please check the format provided in Finnish language.The word "Value" specified as value which are coming in the ALV report against fields mentioned.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!u2014Aromi list -->
<!-- Copyright -->
<!-- Edited with Visual Basic 6 -->
<!-- Versio 1.0 -->
<Tiedot Lahettaja="Value" Yhteyshlo=" Value"
Yhteystieto=" Value " Asiakasnumero="">
<Raaka-aine Nimi="" Ryhma=" Value ">
<Tuotemerkki Nimi=" Value " Ean=" Value "
Ykspakkauskoko="1" Ykspakkaustyyppi="KPL" almistaja="Value">
<Toimittajatiedot Tuotekoodi="10" Sopimustuote="Y" Myyntierakoko="5"
Myyntieratyyppi="ME" Myyntierahinta="3,035" Hintapvm="value"
/>
</Tuotemerkki>
</Raaka-aine>
</Tiedot>
Could anybody help how to download the report data into above format.
Regards,
SachinHi Sachin,
I see the sample XML has field values embedded as XML element attributes.ie <Raaka-aine Ryhma=" Value ">. For such specific requirements:
1. Loop through the table and Use iXML library functions to build the complete XML, element by element. Help - http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
2. You can create an XSLT Transformation that match the specific XML format, and use CALL TRANSFORMATION to convert internal table to that specific XML format.
Few Standard Function modules and class CL_XML_DOCUMENT may help for generic SAP XML conversions, where XML element names will be same as internal table field names. Not, sure if these can be used to generate specific XML formats.
Thanks,
Varun
Edited by: Varun VS on Oct 25, 2011 7:48 AM -
Need help in creating XSD for a WSDL file to tranform given XML
Hi,
Please let me knoe if this is the right forum to post the query below:
We are trying to transform a XML output from a webservice using a XSD file. But we are facing problem as the XML output has some namespace issue and schema due to which transformation is not working fine. I am pasting the files below:
WSDL file used is
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/Projectix20/SOAPAccess" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://tempuri.org/Projectix20/SOAPAccess" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/Projectix20/SOAPAccess">
<s:element name="ExecuteSQLToXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SQL" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="GUID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ExecuteSQLToXMLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ExecuteSQLToXMLResult">
<s:complexType mixed="true">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="NewDataSet">
<s:complexType>
<s:choice>
<s:element minOccurs="0" maxOccurs="unbounded" name="Table1">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="10" name="FName" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:choice>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetDataTablePage">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SQL" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="PageNumber" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="RecordsPerPage" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="GUID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetDataTablePageResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDataTablePageResult">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetRecordCount">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SQL" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="GUID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetRecordCountResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetRecordCountResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UploadCanAtt">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CanID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="Filename" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="bytesData" type="s:base64Binary" />
<s:element minOccurs="0" maxOccurs="1" name="GUID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UploadCanAttResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="UploadCanAttResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DownloadCanAtt">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CanAttID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="GUID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DownloadCanAttResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DownloadCanAttResult" type="s:base64Binary" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="ExecuteSQLToXMLSoapIn">
<wsdl:part name="parameters" element="tns:ExecuteSQLToXML" />
</wsdl:message>
<wsdl:message name="ExecuteSQLToXMLSoapOut">
<wsdl:part name="parameters" element="tns:ExecuteSQLToXMLResponse" />
</wsdl:message>
<wsdl:message name="GetDataTablePageSoapIn">
<wsdl:part name="parameters" element="tns:GetDataTablePage" />
</wsdl:message>
<wsdl:message name="GetDataTablePageSoapOut">
<wsdl:part name="parameters" element="tns:GetDataTablePageResponse" />
</wsdl:message>
<wsdl:message name="GetRecordCountSoapIn">
<wsdl:part name="parameters" element="tns:GetRecordCount" />
</wsdl:message>
<wsdl:message name="GetRecordCountSoapOut">
<wsdl:part name="parameters" element="tns:GetRecordCountResponse" />
</wsdl:message>
<wsdl:message name="UploadCanAttSoapIn">
<wsdl:part name="parameters" element="tns:UploadCanAtt" />
</wsdl:message>
<wsdl:message name="UploadCanAttSoapOut">
<wsdl:part name="parameters" element="tns:UploadCanAttResponse" />
</wsdl:message>
<wsdl:message name="DownloadCanAttSoapIn">
<wsdl:part name="parameters" element="tns:DownloadCanAtt" />
</wsdl:message>
<wsdl:message name="DownloadCanAttSoapOut">
<wsdl:part name="parameters" element="tns:DownloadCanAttResponse" />
</wsdl:message>
<wsdl:portType name="SOAPAccessSoap">
<wsdl:operation name="ExecuteSQLToXML">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Executes a SQL statement and returns a generic XML document with results from SQL statement.</documentation>
<wsdl:input message="tns:ExecuteSQLToXMLSoapIn" />
<wsdl:output message="tns:ExecuteSQLToXMLSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetDataTablePage">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Executes a SQL statement and returns a generic XML document with results from SQL statement.</documentation>
<wsdl:input message="tns:GetDataTablePageSoapIn" />
<wsdl:output message="tns:GetDataTablePageSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetRecordCount">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Executes a SQL statement and returns a generic XML document with results from SQL statement.</documentation>
<wsdl:input message="tns:GetRecordCountSoapIn" />
<wsdl:output message="tns:GetRecordCountSoapOut" />
</wsdl:operation>
<wsdl:operation name="UploadCanAtt">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Uploads a text or binary attachment file for a Candidate record.</documentation>
<wsdl:input message="tns:UploadCanAttSoapIn" />
<wsdl:output message="tns:UploadCanAttSoapOut" />
</wsdl:operation>
<wsdl:operation name="DownloadCanAtt">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Uploads a text or binary attachment file for a Candidate record.</documentation>
<wsdl:input message="tns:DownloadCanAttSoapIn" />
<wsdl:output message="tns:DownloadCanAttSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SOAPAccessSoap" type="tns:SOAPAccessSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="ExecuteSQLToXML">
<soap:operation soapAction="http://tempuri.org/Projectix20/SOAPAccess/ExecuteSQLToXML" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetDataTablePage">
<soap:operation soapAction="http://tempuri.org/Projectix20/SOAPAccess/GetDataTablePage" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetRecordCount">
<soap:operation soapAction="http://tempuri.org/Projectix20/SOAPAccess/GetRecordCount" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UploadCanAtt">
<soap:operation soapAction="http://tempuri.org/Projectix20/SOAPAccess/UploadCanAtt" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="DownloadCanAtt">
<soap:operation soapAction="http://tempuri.org/Projectix20/SOAPAccess/DownloadCanAtt" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SOAPAccess">
<wsdl:port name="SOAPAccessSoap" binding="tns:SOAPAccessSoap">
<soap:address location="http://sales.projectix.com:81/customer/SOAPAccess.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
XSD file used for transformation is:
<?xml version = '1.0' encoding = 'UTF-8'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="ExecuteSQLToXMLResponse">
<xs:complexType>
<xs:sequence>
<xs:element ref="ExecuteSQLToXMLResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="parameters">
<xs:complexType>
<xs:sequence>
<xs:element ref="ExecuteSQLToXMLResponse"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ExecuteSQLToXMLResult">
<xs:complexType>
<xs:sequence>
<xs:element ref="NewDataSet"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="FNAME" type="xs:string"/>
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element ref="FNAME"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Table1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML Output from webservice call that we are trying to tranform using above XSD is:
<parameters >
<ExecuteSQLToXMLResponse xmlns = "http://tempuri.org/Projectix20/SOAPAccess" >
<ExecuteSQLToXMLResult >
<NewDataSet xmlns = "" >
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:msdata = "urn:schemas-microsoft-com:xml-msdata" >
<xs:element name = "NewDataSet" msdata:IsDataSet = "true" >
<xs:complexType >
<xs:choice maxOccurs = "unbounded" >
<xs:element name = "Table1" >
<xs:complexType >
<xs:sequence >
<xs:element name = "FNAME" type = "xs:string" minOccurs = "0" ></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Table1 >
<FNAME >
JOHN
</FNAME>
</Table1>
<Table1 >
<FNAME >
John
</FNAME>
</Table1>
<Table1 >
<FNAME >
John
</FNAME>
</Table1>
<Table1 >
<FNAME >
JOHN
</FNAME>
</Table1>
<Table1 >
<FNAME >
John
</FNAME>
</Table1>
</NewDataSet>
</ExecuteSQLToXMLResult>
</ExecuteSQLToXMLResponse>
</parameters>
I am not sure what we are missing in XSD file that the XML output is not getting transformed correctly...although we tried transforming the XML output by removing some information in XML output above and it was getting trasformed properly..
We remove
1. xmlns = "http://tempuri.org/Projectix20/SOAPAccess" from <ExecuteSQLToXMLResponse xmlns = "http://tempuri.org/Projectix20/SOAPAccess" >
2. xmlns = "" from <NewDataSet xmlns = "" >
3 remove <parameters > and </parameters > tags from output and the XML Output is getting tranformed correctly.
Please let us know if we can transform the XML Output without requiring these removals.
Thanks,
PawanCould you clarify some things? You are saying you are trying to transform the xml output of a webservice with an xsd, but an xsd is a schema that describes the allowed format of a xml file. If you want to transform xml from one format to an other (from one xsd to an other) you have to use a xsl file. You can make and test this with JDeveloper. Are you calling the webservice from esb or bpel?
Kind Regards,
Andre -
Can we generate the output of SQL Query in XML format ..
Hi Team,
Can we generate an XML doc for an SQL Query.
I've seen in SQL Server 2000.It is generating the output of an SQL Query in xml format.
select * from emp for xml auto
The output looks like
<emp EMPNO="7369" ENAME="SMITH" JOB="CLERK" MGR="7902" HIREDATE="1980-12-17T00:00:00" SAL="2800" DEPTNO="20"/><emp EMPNO="7370" ENAME="SMITH" JOB="CLERK" MGR="7902" HIREDATE="1980-12-17T00:00:00" SAL="2800" DEPTNO="10"/>Just a little bit of short hand.
Get the XML out of your database, via HTTP
Of course the easiest method is just to return an XMLType from a stored procedure and let the calling routine figure out what to do with it. Instead
of that way though, I'll show you how to do it via HTTP. It's all completely built into 10g and is super easy to use.
CREATE OR REPLACE VIEW emps_and_depts AS
SELECT e.employee_id AS "EmployeeId",
e.last_name AS "Name",
e.job_id AS "Job",
e.manager_id AS "Manager",
e.hire_date AS "HireDate",
e.salary AS "Salary",
e.commission_pct AS "Commission",
XMLFOREST (
d.department_id AS "DeptNo",
d.department_name AS "DeptName",
d.location_id AS "Location"
) AS "Dept"
FROM employees e, departments d
WHERE e.department_id = d.department_id
Some people hear web and immediately start salivating about security issues. Let me address that quickly. Just because you have the HTTP and/or
FTP servers running in the database, that does not mean you have a security problem. For one, I would hope your databases are behind a firewall.
Second, with the correct architecture (DMZ, app servers, etc) you can make this data available outside the firewall fairly transparently and third,
just because it's on the web does not mean the data MUST be available on the internet. This is a good way to make your data available on your
intranet. If you are worried about people INSIDE your firewall, that still doesn't preclude web based access. Follow Oracle security guidelines.
Before I show you how to get to your data, let's talk about URLs and URIs. A URL is a Uniform Resource Locater and URI is a Uniform Resource
Identifier. A URL is the way you would identify a document on the net, i.e. http://www.oracle.com is a URL. A URI is a more generic form of a URL.
Oracle supports three types of URI: HTTPURIType - basically a URL (which would be like the URL above), XDURIType - a pointer to an XDB resource
(usually an XML document but can be other objects), and DBURIType - a pointer to database objects.
It's the DBURIType that we're going to concentrate on here. The DBURIType let's us reference database objects using a file/folder paradigm. The
format for a DBURI is /oradb/<schema>/<table>. Oradb is shorthand for the database; it is not the database name or SID. My database is named XE
but I still use oradb in the DBURI. For example, the view we created above is in my XE database, is owned by HR (at least in my case) and is called
EMPS_AND_DEPTS. This can be referenced as /oradb/HR/EMPS_AND_DEPTS.
If the view had many rows and you wanted only one of them, you can restrict it by including a predicate. The documentation for XDB has a great
write up on Using DBURIs.In our case, we are going to write out the entire document. Now that you understand that the DBURI is a pointer to
objects in our instance, we can use that to access the data as a URL.
The format for the URL call is http://<machinename>:<port>/<DBURI>
In my case, my XE database is running on a machine called mach1 and is listening on port 8080. So to see the view we created above, I open my
browser and navigate to: http//mach1:8080/oradb/HR/EMPS_AND_DEPTS
The created URL will be as http//mach1:8080/oradb/PUBLIC/EMPS_AND_DEPTS
If your database is set up correctly and listening on port 8080 (the default), your browser should ask you to login. Login as the user who created the
view (in my case HR). You should now get an XML document displayed in your browser.
And that's it. It doesn't get much simpler than that. If you get rid of the descriptive text above, it basically comes down to:
Create a table or view
Open your web browser
Enter a URL
Enter a user ID and password
View your XML
If you notice, Oracle formatted the data as XML for us. Our view returns scalar columns and an XML fragment called Dept. Oracle formatted the
return results into an XML format.
And as a side note, if you look closely, you'll see that my URL has PUBLIC where I said to put HR. PUBLIC is a synonym for all objects that your
logged in user can see. That way, if your user has been granted select access on many schemas, you can use PUBLIC and see any of them. -
Run BW query from R/3, need output file saved on application server
Hello all,
We are currently working on BI 7.0. Is there a way where we can run a BW query from R/3 by some program or tcode? We need to run the BW query and use the output of that query as an input to some other custom program in R/3.
If we can save the output file on application server than the R/3 program will pick up that file from there.
Is there any standard delivered functionality that will allow us to do that or how can we achieve this.
Can some help help with some suggestions or links?
Thanks in advance.Hi,
Refer the following threads:
[Calling BW Query from R/3;
[Saving Bex Report / query in BW App server;
Regards. -
Hi,
I want to generate xml output of a query.
( suppose if i write select * from tab1 ; then i want all the rows from the table tab1 in xml form )
how to do it.. ?
plz guide.I guess what you are loooking for is this
select xmltype(cursor(select * from dept)).getclobval() from dual;
this will give you the outout in a txt viewable format.
Rushi -
Hi All
I am new to MDX language and need a MDX functions/query on the cube to get the required output, Given below is the scenario with the data.
I am maintaining the data in a table in dataMart with given structure. We have the data at day and weekly in a single table with granularity indicator and count is the measure group column. While loading the data in to mart table we are populaiting the week
Key from week table and Month key from month table and joining in the cube.
we need to calculate the inventory for a particular month. If a user selects a particular month the output would be count = 30 as a measure called Closed and count = 16 as a measure value called Open.
Need a MDX query to get output.
Granularity Count WeekKey MonthKey
Weekly 16
W1 M1
Weekly 17
W1 M1
Weekly 18
w1 M1
Weekly 19
W1 M1
Weekly 20
W1 M1
Weekly 21
W1 M1
Weekly 22
W1 M1
Weekly 23
w2 M1
Weekly 24
w2 M1
Weekly 25
w2 M1
Weekly 26
w2 M1
Weekly 27
w2 M1
Weekly 28
w2 M1
Weekly 29
w2 M1
Weekly 30
w2 M1
Weekly 16
w3 M1
Weekly 17
w3 M1
Weekly 18
w3 M1
Weekly 19
w3 M1
Weekly 20
w3 M1
Weekly 21
w3 M1
Weekly 22
w3 M1
Weekly 23
w4 M1
Weekly 24
w4 M1
Weekly 25
w4 M1
Weekly 26
w4 M1
Weekly 27
w4 M1
Weekly 28
w4 M1
Weekly 29
w4 M1
Weekly 30
w4 M1
Thanks in advanceHi Venkatesh,
According to your description, you need to count the members with conditions in a particular month, right?
In MDX, we can achieve the requirement by using Count and Filter function, I have tested it on AdventureWorks cube, the sample query below is for you reference.
with member [ConditionalCount]
as
count(filter([Date].[Calendar].[Month].&[2008]&[2].children,[Measures].[Internet Order Count]>50))
select {[Measures].[Internet Order Count],[ConditionalCount]} on 0,
[Date].[Calendar].[Date].members on 1
from
(select [Date].[Calendar].[Month].&[2008]&[2] on 0 from
[Adventure Works]
Reference
http://msdn.microsoft.com/en-us/library/ms144823.aspx
http://msdn.microsoft.com/en-us/library/ms146037.aspx
If this is not what you want, please elaborate your requirement, such as the detail structure of your cube, so that we can make further analysis.
Regards,
Charlie Liao
TechNet Community Support -
How to extract the nodes of any given XML document ???
Hello,
Greetings! It is an interesting forum.
A Snippet of XML Schema PurchaseOrder.xsd as given in user guide is as follows
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
version="1.0" xdb:storeVarrayAsTable="true">
<xs:element name="PurchaseOrder" type="PurchaseOrderType"
xdb:defaultTable="PURCHASEORDER"/>
<xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T">
<xs:sequence>
<xs:element name="Reference" type="ReferenceType" minOccurs="1"
xdb:SQLName="REFERENCE"/>
<xs:element name="Actions" type="ActionsType" xdb:SQLName="ACTIONS"/>
<xs:element name="Reject" type="RejectionType" minOccurs="0"
xdb:SQLName="REJECTION"/>
<xs:element name="Requestor" type="RequestorType"
xdb:SQLName="REQUESTOR"/>
<xs:element name="User" type="UserType" minOccurs="1"
xdb:SQLName="USERID"/>
<xs:element name="CostCenter" type="CostCenterType"
xdb:SQLName="COST_CENTER"/>
<xs:element name="ShippingInstructions" type="ShippingInstructionsType"
xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
<xs:element name="SpecialInstructions" type="SpecialInstructionsType"
xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
<xs:element name="LineItems" type="LineItemsType"
xdb:SQLName="LINEITEMS"/>
</xs:sequence>
</xs:complexType>
full schema is available in url
http://download-west.oracle.com/docs/cd/B12037_01/appdev.101/b10790/xdb03usg.htm#BABBGIED
The views use XPath expressions and functions such as extractValue() to define the mapping between columns in the view and nodes in the XML document. The following view is created on purchase order schema.
Creating Relational Views On XML Content
CREATE OR REPLACE view PURCHASEORDER_MASTER_VIEW
(REFERENCE, REQUESTOR, USERID, COSTCENTER,
SHIP_TO_NAME,SHIP_TO_ADDRESS, SHIP_TO_PHONE,
INSTRUCTIONS)
AS
SELECT extractValue(value(p),'/PurchaseOrder/Reference'),
extractValue(value(p),'/PurchaseOrder/Requestor'),
extractValue(value(p),'/PurchaseOrder/User'),
extractValue(value(p),'/PurchaseOrder/CostCenter'),
extractValue(value(p),'/PurchaseOrder/ShippingInstructions/name'),
extractValue(value(p),'/PurchaseOrder/ShippingInstructions/address'),
extractValue(value(p),'/PurchaseOrder/ShippingInstructions/telephone'),
extractValue(value(p),'/PurchaseOrder/SpecialInstructions')
FROM PURCHASEORDER p;
When we register XML Schema in Oracle 9i, the schema elements of XML documents are stored as XMLType, that is, stored using object-relational storage techniques.
For a small schema, we could build the above view manually, but for large/nested schema, if we have query to build XML documents node list, it will help us to build Relational Views on XML Content.
How do we extract the nodes of any given XML document through O-R structures or XML DB using XML DB functions?
Any alternate thoughts are welcome.
I appreciate your help.
Regards
RamRam
Once again, I do not think that you can solve the problem you are trying to solve. Fundamentally you need to determine for a given element of a given complex type what are it's child elements. For each of those elements you then need to find out whether or not it in turn has child elements...
Then you have to think about elements defined as ref rather than type, elements that are substituteable, and the rest of possibilities that can be described with XML Schema.
If you can solve that problem you're a better man than I as the saying goes. Anyone rather than give you a fish, I'll show you how to at least put a worm on the hook..
The following query gets the names of the elements inside a each of the global complex types
Good luck, if you come up with a query to do this I'd love to see it...
SQL> column COMPLEX_TYPE format A32
SQL> column ELEMENT format A32
SQL> --
SQL> select extractvalue
2 (
3 value(ct),
4 '/xs:complexType/@name',
5 'xmlns:xs="http://www.w3.org/2001/XMLSchema"'
6 ) COMPLEX_TYPE,
7 extractvalue
8 (
9 value(et),
10 '/xs:element/@name',
11 'xmlns:xs="http://www.w3.org/2001/XMLSchema"'
12 ) ELEMENT
13 from resource_view,
14 table
15 (
16 xmlsequence
17 (
18 extract
19 (
20 res,
21 '/r:Resource/r:Contents/xs:schema/xs:complexType',
22 'xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd"
23 xmlns:xs="http://www.w3.org/2001/XMLSchema"')
24 )
25 ) ct,
26 table
27 (
28 xmlsequence
29 (
30 extract
31 (
32 value(ct),
33 '/xs:complexType/*/xs:element',
34 'xmlns:xs="http://www.w3.org/2001/XMLSchema"'
35 )
36 )
37 ) et
38 where equals_path(res,'/home/SCOTT/poSource/xsd/purchaseOrder.xsd') = 1
39 /
COMPLEX_TYPE ELEMENT
-------------------------------- ------------------------PurchaseOrderType Reference
PurchaseOrderType Actions
PurchaseOrderType Reject
PurchaseOrderType Requestor
PurchaseOrderType User
PurchaseOrderType CostCenter
PurchaseOrderType ShippingInstructions
PurchaseOrderType SpecialInstructions
PurchaseOrderType LineItems
LineItemsType LineItem
LineItemType Description
LineItemType Part
ActionsType Action
RejectionType User
RejectionType Date
RejectionType Comments
ShippingInstructionsType name
ShippingInstructionsType address
ShippingInstructionsType telephone
19 rows selected. -
Smartforms output in XML format
Hi everyone,
I am very new for smartforms and my requirement to convrt given smartform in XML format, I am going through
Form Attributes -> output options -> output format -> XSF output , then I am giving proper value in output mode & in Output Device but not getting proper output, can You please tell me what i have to do (in Detail ) ?
Thanks & Regards,
Vimarsh B.Hi Abhinay
I have billing order invoice, client is getting its output in standard format but now he needs the output of that form has to come in XML format, if we are using standard output format in form attributes, its showing output but when we are chenging its option we are not getting any output, only one spool create, and we are not able to understand what exactly output will come, it will come same like standard format or only spool will create and if only spool create then how we can send it to our client. please solve this issue, thanks for ur support.
Thanks & Regards,
Vimarsh B.
Maybe you are looking for
-
How do I print email from android Samsung Galaxy 3?
CANNOT ABLE TO PRINT FROM HP M1005 THOUGH SAMSUNG GALAXY S3 BY OTG CALE.
-
I cant upload my music from p.c windows and android (samsung galexy 3) to iphone 4. and icloud isnt copying it either. very frustraiting and starting to regrete getting an iphone :-( please help if your able. Thankyou.
-
my wrt54g has been having a problem with running very slow linksys sent me a new one but it is doing the same after a short time. If i connect right to my modem to my pc that is a very fast connection can any one help me thanks jim
-
Does any one know how can i install mb worksuite 2014 on my mac pro
how can I install mb Work suite 2014 on my mac
-
Does anyone know how I can display an item price on the PO form instead of the default 1. I updated the item price but when you create a PO the price still defaults to 1 Thanks Roald