Generating XML for query resultset
hi,
how to generate xml file for a query,,in sql server we use:
select * from emp
for auto xml do;
it generates xml file for the result set of this query,,how to do it in oracle??
regards
umar
Use dbms_xmlgen.getxml.
Tom kyte has some good stuff at his site.
http://asktom.oracle.com/pls/ask/f?p=4950:8:4444542233908715904::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:16020931845088,
Similar Messages
-
Cannot generate XML for the List of Values (UX 00072)
Hi,
I had issues with a .LOV file associated with an object.
Cannot generate XML for the List of Values (UX 00072)
[LOV Name] This LOV contains data that does not originate from Corporate Data.
The object maps to data in a table of the DB that will be populated in the future. The LOV file is "empty", but I have to pass the universe into production waiting for the data.
This error doesn't permit me to go from Development to Prod.
Regards,
RiccardoYou need to set the display-property="<<Your name property>>" in item-descriptor tag.
e.g. <item-descriptor name="myItem" display-property="name" />
Cheers
R -
Generating XML for an instance of a custom type
I apologize for a silly question...
How do I use the codec object that <autotype> generates for a custom type?
The schema and WSDL files are written by hand, <autotype> generates java representation
of the types along with serializer/deserializer classes for nested types and the
main codec class fine. Now I need to manually generate XML for a particular instance
of my custom type (at runtime). The codec class declares XML_TYPE as a private
variable while it seems to be exactly what needs to be passed to codec’s serialize(),
and the codec class is a final class... so how’s this class supposed to be used?
Same with de-serialization.
Any help will be greatly appreciated!
Dmitriyalso see http://edocs.bea.com/wls/docs81/webserv/customdata.html#1052981
Bruce Stephens wrote:
>
Hi Dimtriy,
I've attached an example using a custom codec with clientgen. If you
could take a look and see if this ser/deser can provide you with some
guidelines on what is required. Also, if you could bundle a small
example that illustrates your custom type, it would be helpful.
Thanks,
Bruce
Dmitriy Myaskovskiy wrote:
I apologize for a silly question...
How do I use the codec object that <autotype> generates for a custom type?
The schema and WSDL files are written by hand, <autotype> generates java representation
of the types along with serializer/deserializer classes for nested types and the
main codec class fine. Now I need to manually generate XML for a particular instance
of my custom type (at runtime). The codec class declares XML_TYPE as a private
variable while it seems to be exactly what needs to be passed to codec’s serialize(),
and the codec class is a final class... so how’s this class supposed to be used?
Same with de-serialization.
Any help will be greatly appreciated!
Dmitriy------------------------------------------------------------------------
Name: custom_codec.zip
custom_codec.zip Type: Zip Compressed Data (application/x-zip-compressed)
Encoding: base64 -
How to generate XML for following?
Hello Everyone,
I have following snippet of PLSQL code with for loops and record type arrays. Each loop can return separate number of rows and iterate that many times. For e.g. the for loop tab_rec may fetch 50 rows where as the for loop sql_rec may return 80 rows.
I need to acoomodate all of these record arrays into a single xml file. Each for loop will repreesent one data set. Something like this.
<dataset>
<set value = tab_rec(kounter).tvalue >
<set value = ?
</dataset>
Questions:
1) How can I dynamically generate just one single XML file for all for loops metnioend below in this message?
2) How can I dynamically generate tags for e.g. <set> tag above if I put XMLELEMENT() under a for loop kounter. To explain this in a better way consider pseudo code example below.
for i in 1..kounter loop
<dataset>
<set value = tab_rec(i).tvalue >
*<set value = *?* -- How do i generate these <set> tags when tebrec(i).value will return many rows?*_
</dataset>
Thanks for reading this post. Again, the exmple for loops to generate one single XML file is given below.
For loops in the issue are mentioned below
FOR a IN tab_recc
LOOP
tab_rec (tab_kounter).tsegment := a.ebs_table;
tab_rec (tab_kounter).tbytes := a.sizemb;
tab_kounter := tab_kounter + 1;
END LOOP;
FOR b IN sql_recc
LOOP
sql_rec (sql_kounter).thash := b.hash_value;
sql_rec (sql_kounter).texecution_read := b.reads_per_execution;
sql_kounter := sql_kounter + 1;
END LOOP;
FOR c IN sess_recc
LOOP
sess_rec (session_kounter).tsid := c.SID;
sess_rec (session_kounter).tvalue := c.VALUE;
session_kounter := session_kounter + 1;
END LOOP;
FOR d IN user_recc
LOOP
user_rec (dbuser_kounter).tphysical_reads := d.physical_reads;
user_rec (dbuser_kounter).tuser := d.username;
dbuser_kounter := dbuser_kounter + 1;
END LOOP;
FOR e IN ebs_user
LOOP
ebs_rec (ebs_kounter).tuser := e.user_name;
ebs_rec (ebs_kounter).ttime := e.rtime;
ebs_kounter := ebs_kounter + 1;
END LOOP;Sorry for delay in response.
I have pasted the complete code that will show the relation ship between data and XML. What I am trying to do here is to prepare smal packets of XML through XML element and then roll it up to a final grand CLOB variable. and pass that through XML creation. I have used DBMS_JAVA package to append clobs.
The issue now I am running into, it generates JUNK in xml. pure junk and nothing else Thanks R,
FOR a IN tab_recc
LOOP
tab_rec (tab_kounter).tsegment := a.ebs_table;
tab_rec (tab_kounter).tbytes := a.sizemb;
tab_kounter := tab_kounter + 1;
END LOOP;
FOR b IN sql_recc
LOOP
sql_rec (sql_kounter).thash := b.hash_value;
sql_rec (sql_kounter).texecution_read := b.reads_per_execution;
sql_kounter := sql_kounter + 1;
END LOOP;
FOR c IN sess_recc
LOOP
sess_rec (session_kounter).tsid := c.SID;
sess_rec (session_kounter).tvalue := c.VALUE;
session_kounter := session_kounter + 1;
END LOOP;
FOR d IN user_recc
LOOP
user_rec (dbuser_kounter).tphysical_reads := d.physical_reads;
user_rec (dbuser_kounter).tuser := d.username;
dbuser_kounter := dbuser_kounter + 1;
END LOOP;
FOR e IN ebs_user
LOOP
ebs_rec (ebs_kounter).tuser := e.user_name;
ebs_rec (ebs_kounter).ttime := e.rtime;
ebs_kounter := ebs_kounter + 1;
END LOOP;
FOR aa IN 1 .. tab_kounter
LOOP
if aa = 1 then
SELECT XMLELEMENT
("dataset",
xmlattributes (v_top50id1 AS "Id"),
XMLELEMENT ("set",
xmlattributes (aa AS "Id",
tab_rec (aa).tsegment AS "value"
).getclobval ()
INTO tablob --clob type
FROM DUAL;
end if;
END LOOP;
FOR bb IN 1 .. sql_kounter
LOOP
if bb = 1 then
SELECT XMLELEMENT
("dataset",
xmlattributes (v_top50id2 AS "Id"),
XMLELEMENT ("set",
xmlattributes (bb AS "Id",
sql_rec (bb).thash AS "value"
).getclobval ()
INTO sqlob --clob type
FROM DUAL;
end if;
END LOOP;
FOR cc IN 1 .. session_kounter
LOOP
if cc= 1 then
SELECT XMLELEMENT
("dataset",
xmlattributes (v_top50id3 AS "Id"),
XMLELEMENT ("set",
xmlattributes (cc AS "Id",
sess_rec (cc).tsid AS "value"
).getclobval ()
INTO sesslob --clob type
FROM DUAL;
end if;
END LOOP;
FOR dd IN 1 .. dbuser_kounter
LOOP
if dd = 1 then
SELECT XMLELEMENT
("dataset",
xmlattributes (v_top50id4 AS "Id"),
XMLELEMENT ("set",
xmlattributes (dd AS "Id",
user_rec (dd).tuser AS "value"
).getclobval ()
INTO dbulob --clob type
FROM DUAL;
end if;
END LOOP;
FOR ee IN 1 .. ebs_kounter
LOOP
if ee = 1 then
SELECT XMLELEMENT
("dataset",
xmlattributes (v_top50id5 AS "Id"),
XMLELEMENT ("set",
xmlattributes (ee AS "Id",
ebs_rec (ee).tuser AS "value"
).getclobval ()
INTO ebslob --clob type
FROM DUAL;
end if;
END LOOP;
SELECT XMLELEMENT
("Chart",
xmlattributes (v_caption AS "caption",
v_subcaption AS "shownames",
v_xaxisname AS "showvalues",
v_yaxisname AS "decimals"
XMLELEMENT ("categories",
XMLELEMENT ("category",
xmlattributes (v_label1 AS "label")
XMLELEMENT ("category",
xmlattributes (v_label2 AS "label")
XMLELEMENT ("category",
xmlattributes (v_label3 AS "label")
XMLELEMENT ("category",
xmlattributes (v_label4 AS "label")
XMLELEMENT ("category",
xmlattributes (v_label5 AS "label")
XMLELEMENT ("category",
xmlattributes (v_label6 AS "label")
tablob, --clob type
sqlob, --clob type
sesslob, --clob type
dbulob, --clob type
ebslob --clob type
).getclobval ()
INTO v_top50 --clob type
FROM DUAL;
DBMS_LOB.append (v_xmlmessage, v_top50); --both are clob type
v_filename := 'Top50.xml';
writexml (p_dir_path => v_dir_path,
p_filename => v_filename,
p_xml => v_xmlmessage
); -
I have seen this cool feature of generating XML sample file for a give XSD in XMLSPY. Is the same available in XDK by any chance through some PL/SQL API. We have this requirement in our product. Thanks.
I have not run across this capability, but I haven't read everything.
tom -
MX 6 - prob generating xml for gallery example
See
http://coolabah.com/spry/demos/gallery/xml.cfm
I have MX 6 and think this is a problem.
I can generate what looks like xml in the browser, but when I
try to save it to a file I get this sort of output for the above,
<style>
table.cfdump_wddx,
table.cfdump_xml,
table.cfdump_struct,
table.cfdump_array,
table.cfdump_query,
table.cfdump_cfc,
table.cfdump_object,
table.cfdump_binary,
table.cfdump_udf,
table.cfdump_udfbody,
table.cfdump_udfarguments {
font-size: xx-small;
font-family: verdana, arial, helvetica, sans-serif;
cell-spacing: 2;
etc.
Can anyone help?
Thanks,
KateYou shouldn't search for line 145 into the CFM file but into
the answer that is sent to the browser. The resulting XML sent by
the CFM is invalid so you have to identify first the line 145 into
the response and than to look where the line is generated.
As Don did I opened the URL into Firefox and when the XML
error displayed I look into the source (View Source). The server
instead of serving a valid XML answer a HTML content which is not
correct. (Maybe a CF server error ?!)
Cristian -
Generate XML for a COBOL Copy Book
Hi All,
How to generate an XML document out of a COBOL copy book. Can i get some sample code for a simple cobol copy book.
Thanks
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Nataraj Vankadara ([email protected]):
Hi All,
How to generate an XML document out of a COBOL copy book. Can i get some sample code for a simple cobol copy book.
Thanks<HR></BLOCKQUOTE>
Check for the functionality of Datajunction utilities.
I don't know what is Cobol copy book, but these utilitys has many functionality for converting any datasource to/from XML, including cobol.
Best regards, Marcelo.
null -
Hi,
I try to generate an XML DOM with XSU using the constructor OracleXMLQuery(java.sql.Connection conn,
java.sql.ResultSet rset)
When I pass a resultset object made by a classic statement, it's OK
But when I pass a resultset made by a callable statement :
ResultSet rs = (ResultSet)callStmt.getArray(7)).getResultSet(); it's not ok
The first implementation of ResultSet is OracleResultSetImpl, the second implementation is ArrayDataResultSet.
I think the XSU expect an OracleResultSetImpl Implementation of the resultset.
What can I do ?
Thank youHi,
Which Database Server you are using ? If you are using SQL Server 2000, you can directly call save method() on resultset object & save into XML file.
Else you can traverse through resultset using while loop & append the values to string with whatever node names you want, then after you can write that string into the XML file.
Try this out.
Ajay. -
Im generating some xml from a table which works fine. Here is an example of what Im doing.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
create table "VTEST"(
"PROJECT_NUMBER" VARCHAR2(50 BYTE),
"ORDER_NUMBER" VARCHAR2(50 BYTE),
"PART_NUMBER" VARCHAR2(50 BYTE),
"COMPANY_NAME" VARCHAR2(50 BYTE),
"PART_DESCRIPTION" VARCHAR2(50 BYTE),
"PART_DETAILS" VARCHAR2(50 BYTE),
"SUB_NUMBER" VARCHAR2(50 BYTE)
--DROP TABLE VTEST
INSERT INTO vtest VALUES(12345, 111, 19,'COMPANY1','DESC1','DETAILS1',999);
INSERT INTO vtest VALUES(12387, 111, 25,'COMPANY2','DESC2','DETAILS2',888);
INSERT INTO vtest VALUES(12343, 569, 96,'COMPANY3','DESC3','DETAILS3',777);
INSERT INTO vtest VALUES(12340, 274, 13,'COMPANY4','DESC4','DETAILS4',666);
INSERT INTO vtest VALUES(15645, 385, 13,'COMPANY5','DESC5','DETAILS5',555);
INSERT INTO vtest VALUES(22347, 996, 13,'COMPANY6','DESC6','DETAILS6',444);
INSERT INTO vtest VALUES(35622, 825, 13,'COMPANY1','DESC7','DETAILS7',333);
INSERT INTO vtest VALUES(42335, 111, 19,'COMPANY1','DESC8','DETAILS8',222);
--SELECT * FROM VTEST
SELECT
XMLElement("APP",
XMLAttributes('VTEST' as "NAME")
, XMLElement("WEB",
XMLAgg(
XMLElement("PROJECT_NUMBER",
XMLAttributes(NVL("ORDER_NUMBER",' ') AS ORDER_NUMBER,
NVL("PART_NUMBER",' ') AS PART_NUMBER,
NVL("COMPANY_NAME",' ') AS COMPANY_NAME,
NVL("PART_DESCRIPTION",' ') AS PART_DESCRIPTION,
NVL("PART_DETAILS",' ') AS PART_DETAILS,
NVL("SUB_NUMBER",' ') AS SUB_NUMBER
XMLForest(
NVL("ORDER_NUMBER",' ') AS ORDER_NUMBER,
NVL("PART_NUMBER",' ') AS PART_NUMBER,
NVL("COMPANY_NAME",' ') AS COMPANY_NAME,
NVL("PART_DESCRIPTION",' ') AS PART_DESCRIPTION,
NVL("PART_DETAILS",' ') AS PART_DETAILS,
NVL("SUB_NUMBER",' ') AS SUB_NUMBER
FROM VTEST
this works fine.
But I would also like to generate a second xml where each section is listed with unique values like so :
<APP NAME="VTEST">
<WEB>
<ORDER_NUMBERS>
<ORDER_NUMBER>111</ORDER_NUMBER>
<ORDER_NUMBER>569</ORDER_NUMBER>
<ORDER_NUMBER>274</ORDER_NUMBER>
<ORDER_NUMBER>385</ORDER_NUMBER>
<ORDER_NUMBER>996</ORDER_NUMBER>
<ORDER_NUMBER>825</ORDER_NUMBER>
</ORDER_NUMBERS>
<PART_NUMBERS>
<PART_NUMBER>19</PART_NUMBER>
<PART_NUMBER>25</PART_NUMBER>
<PART_NUMBER>96</PART_NUMBER>
<PART_NUMBER>13</PART_NUMBER>
</PART_NUMBERS>
<COMPANIES>
<COMPANY_NAME>COMPANY1</COMPANY_NAME>
<COMPANY_NAME>COMPANY2</COMPANY_NAME>
<COMPANY_NAME>COMPANY3</COMPANY_NAME>
<COMPANY_NAME>COMPANY4</COMPANY_NAME>
<COMPANY_NAME>COMPANY5</COMPANY_NAME>
<COMPANY_NAME>COMPANY6</COMPANY_NAME>
</COMPANIES>
<PART_DESCRIPTIONS>
<PART_DESCRIPTION>DESC1</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC2</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC3</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC4</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC5</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC6</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC7</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC8</PART_DESCRIPTION>
</PART_DESCRIPTIONS>
<PART_DETAILS>
<PART_DETAILS>DETAILS1</PART_DETAILS>
<PART_DETAILS>DETAILS2</PART_DETAILS>
<PART_DETAILS>DETAILS3</PART_DETAILS>
<PART_DETAILS>DETAILS4</PART_DETAILS>
<PART_DETAILS>DETAILS5</PART_DETAILS>
<PART_DETAILS>DETAILS6</PART_DETAILS>
<PART_DETAILS>DETAILS7</PART_DETAILS>
<PART_DETAILS>DETAILS8</PART_DETAILS>
</PART_DETAILS>
<SUB_NUMBERS>
<SUB_NUMBER>999</SUB_NUMBER>
<SUB_NUMBER>888</SUB_NUMBER>
<SUB_NUMBER>777</SUB_NUMBER>
<SUB_NUMBER>666</SUB_NUMBER>
<SUB_NUMBER>555</SUB_NUMBER>
<SUB_NUMBER>444</SUB_NUMBER>
<SUB_NUMBER>333</SUB_NUMBER>
<SUB_NUMBER>222</SUB_NUMBER>
</SUB_NUMBERS>
</WEB>
</APP>
Ive been trying and just cant figure it out . so each section would list its unique values.
thanks for any help.Here's a way to avoid accessing the table multiple times:SELECT xmlserialize(content
XMLElement("APP",
XMLAttributes('VTEST' as "NAME")
, XMLElement("WEB",
xmlelement(
PROJECT_NUMBERS,
xmlagg(case when col = 'PROJECT_NUMBER' then xmlelement(PROJECT_NUMBER, val) end)
xmlelement(
ORDER_NUMBERS,
xmlagg(case when col = 'ORDER_NUMBER' then xmlelement(ORDER_NUMBER, val) end)
xmlelement(
PART_NUMBERS,
xmlagg(case when col = 'PART_NUMBER' then xmlelement(PART_NUMBER, val) end)
xmlelement(
COMPANY_NAMES,
xmlagg(case when col = 'COMPANY_NAME' then xmlelement(COMPANY_NAME, val) end)
xmlelement(
PART_DESCRIPTIONS,
xmlagg(case when col = 'PART_DESCRIPTION' then xmlelement(PART_DESCRIPTION, val) end)
xmlelement(
PART_DETAILSS,
xmlagg(case when col = 'PART_DETAILS' then xmlelement(PART_DETAILS, val) end)
xmlelement(
SUB_NUMBERS,
xmlagg(case when col = 'SUB_NUMBER' then xmlelement(SUB_NUMBER, val) end)
) indent)
from (
select distinct col, val from vtest
unpivot(val for col in(
PROJECT_NUMBER,ORDER_NUMBER,PART_NUMBER,COMPANY_NAME,PART_DESCRIPTION,PART_DETAILS,SUB_NUMBER
order by val
<APP NAME="VTEST">
<WEB>
<PROJECT_NUMBERS>
<PROJECT_NUMBER>12340</PROJECT_NUMBER>
<PROJECT_NUMBER>12343</PROJECT_NUMBER>
<PROJECT_NUMBER>12345</PROJECT_NUMBER>
<PROJECT_NUMBER>12387</PROJECT_NUMBER>
<PROJECT_NUMBER>15645</PROJECT_NUMBER>
<PROJECT_NUMBER>22347</PROJECT_NUMBER>
<PROJECT_NUMBER>35622</PROJECT_NUMBER>
<PROJECT_NUMBER>42335</PROJECT_NUMBER>
</PROJECT_NUMBERS>
<ORDER_NUMBERS>
<ORDER_NUMBER>111</ORDER_NUMBER>
<ORDER_NUMBER>274</ORDER_NUMBER>
<ORDER_NUMBER>385</ORDER_NUMBER>
<ORDER_NUMBER>569</ORDER_NUMBER>
<ORDER_NUMBER>825</ORDER_NUMBER>
<ORDER_NUMBER>996</ORDER_NUMBER>
</ORDER_NUMBERS>
<PART_NUMBERS>
<PART_NUMBER>13</PART_NUMBER>
<PART_NUMBER>19</PART_NUMBER>
<PART_NUMBER>25</PART_NUMBER>
<PART_NUMBER>96</PART_NUMBER>
</PART_NUMBERS>
<COMPANY_NAMES>
<COMPANY_NAME>COMPANY1</COMPANY_NAME>
<COMPANY_NAME>COMPANY2</COMPANY_NAME>
<COMPANY_NAME>COMPANY3</COMPANY_NAME>
<COMPANY_NAME>COMPANY4</COMPANY_NAME>
<COMPANY_NAME>COMPANY5</COMPANY_NAME>
<COMPANY_NAME>COMPANY6</COMPANY_NAME>
</COMPANY_NAMES>
<PART_DESCRIPTIONS>
<PART_DESCRIPTION>DESC1</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC2</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC3</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC4</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC5</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC6</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC7</PART_DESCRIPTION>
<PART_DESCRIPTION>DESC8</PART_DESCRIPTION>
</PART_DESCRIPTIONS>
<PART_DETAILSS>
<PART_DETAILS>DETAILS1</PART_DETAILS>
<PART_DETAILS>DETAILS2</PART_DETAILS>
<PART_DETAILS>DETAILS3</PART_DETAILS>
<PART_DETAILS>DETAILS4</PART_DETAILS>
<PART_DETAILS>DETAILS5</PART_DETAILS>
<PART_DETAILS>DETAILS6</PART_DETAILS>
<PART_DETAILS>DETAILS7</PART_DETAILS>
<PART_DETAILS>DETAILS8</PART_DETAILS>
</PART_DETAILSS>
<SUB_NUMBERS>
<SUB_NUMBER>222</SUB_NUMBER>
<SUB_NUMBER>333</SUB_NUMBER>
<SUB_NUMBER>444</SUB_NUMBER>
<SUB_NUMBER>555</SUB_NUMBER>
<SUB_NUMBER>666</SUB_NUMBER>
<SUB_NUMBER>777</SUB_NUMBER>
<SUB_NUMBER>888</SUB_NUMBER>
<SUB_NUMBER>999</SUB_NUMBER>
</SUB_NUMBERS>
</WEB>
</APP> -
Hi,
I have a problem with a customer, he was using SAP Business One 9.0 pl 9 and everything works fine.
When he upgrade to SAP Business One 9.0 pl 11 the eInvoice that was working on the patch level 9 stop working, but when i try to generate de new XML the file is incomplete, I attach the file of the new file XML generate in version 9.0 pl 11
Please any help.
Regards!!!
David AlmazánHi San Xu
That is my exact issue, I generate from my PC and appears incomplete, Generate from my customers productive System and its the same, Ive almost upgrade to PL12 and still with the problem.
Any ideas or post a message to SAP?
Regards David -
Generate xml using FOR XML PATH from table with hierarchy
I need to create xml from a table like:
EL1 EL2 EL3 Attr01 Attr02 Attr03 Attr04
E10, , ,a,b,c,d
E10,E1010, ,a,b,c,d
E10,E1010,E101010,a,b,c,d
E10,E1010,E101020,a,b,c,d
E10,E1010,E101030,a,b,c,d
E10,E1020, ,a,b,c,d
E10,E1020,E102010,a,b,c,d
E20, , ,a,b,c,d
E20,E2010, ,a,b,c,d
E20,E2010,E201010,a,b,c,d
E20,E2020, ,a,b,c,d
E20,E2020,E202010,a,b,c,d
E20,E2020,E202020,a,b,c,d
The hierarchy is EL1--EL2--EL3, and the 3 columns should be elements of xml;
The other for columns Attr01,Attr02,Attr03,Attr04 should be attributes of xml;
The actual table could have more than 500 rows(there are many values for El1,EL2,and EL3).
The expected xml should like:
<root>
<E10 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E1010 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E101010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
<E101020 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
<E101030 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E1010>
<E1020 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E102010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E1020>
</E10>
<E20 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E2010 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E201010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E2010>
<E2020 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E202010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
<E202020 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E2020>
</E20>
</root>
I create a sample Src table:
CREATE TABLE Src
EL1 VARCHAR(10),
EL2 VARCHAR(10),
EL3 VARCHAR(10),
Attr01 VARCHAR(10),
Attr02 VARCHAR(10),
Attr03 VARCHAR(10),
Attr04 VARCHAR(10)
GO
INSERT INTO Src
(EL1,EL2,EL3,Attr01,Attr02,Attr03,Attr04
SELECT 'E10','','','a','b','c','d'
UNION SELECT 'E10','E1010','','a','b','c','d'
UNION SELECT 'E10','E1010','E101010','a','b','c','d'
UNION SELECT 'E10','E1010','E101020','a','b','c','d'
UNION SELECT 'E10','E1010','E101030','a','b','c','d'
UNION SELECT 'E10','E1020','','a','b','c','d'
UNION SELECT 'E10','E1020','E102010','a','b','c','d'
UNION SELECT 'E20','','','a','b','c','d'
UNION SELECT 'E20','E2010','','a','b','c','d'
UNION SELECT 'E20','E2010','E201010','a','b','c','d'
UNION SELECT 'E20','E2020','','a','b','c','d'
UNION SELECT 'E20','E2020','E202010','a','b','c','d'
UNION SELECT 'E20','E2020','E202020','a','b','c','d'
GO
I tried to use FOR XML PATH to generate xml for the sample data. When the records increase to a few hundreds, it's not a good idea.
Here is my script:
SELECT
(SELECT Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E101010'
FOR XML PATH('E101010'),TYPE
) AS 'node()'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E101020'
FOR XML PATH('E101020'),TYPE
) AS 'node()'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E101030'
FOR XML PATH('E101030'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E1010' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E1010'),TYPE
) AS 'node()'--1010
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E102010'
FOR XML PATH('E102010'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E1020' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E1020'),TYPE
) AS 'node()'--1020
FROM Src
WHERE EL1 = 'E10' AND (EL2 ='' AND EL3 ='')
FOR XML PATH('E10'),TYPE) 'node()'
,(SELECT Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E201010'
FOR XML PATH('E201010'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E2010' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E2010'),TYPE
) AS 'node()'--2010
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E202010'
FOR XML PATH('E202010'),TYPE
) AS 'node()'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E202020'
FOR XML PATH('E202020'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E2020' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E2020'),TYPE
FROM Src
WHERE EL1 = 'E20' AND (EL2 ='' AND EL3 ='')
FOR XML PATH('E20'),TYPE) AS 'node()'
FOR XML PATH(''),ROOT('root')
If I get a few hundreds of rows, how huge the script should be. Does anyone have better solution for this? Thanks.
TaowBob,
Thanks! And sorry for late feedback.
The XSD requires the xml structures like the following
<Schools>
<School01>Some school</School01>
<School02>Some other school</School02>
</Schools>
I have to use the number in the element name.
Right now I just use the nested FOR XML PATH, although I have to write thousand lines code.
Thanks anyway.
Tao
Tao -
Issues in generating xml from Report Builder as per XSD provided
Hi,
We are provided with XSD's for each report. Now we need to generate XML's from report that are as per the XSD's provided to us.
But the problem come's when we have to define hirearchies.
Like for example
1. Our Report is based on the following query:
SELECT DISTINCT '' as DUMMY
, fil.file_number
, TO_CHAR (TO_DATE (RTRIM (LTRIM (fil.processing_date)), 'YYDDD'),'DD-MM-YY') Processing_Dt
, rp_bsu.service_user_number
, rp_bsu.service_user_name
, rp_ac.account_number
, rp_ac.account_name
, rp_ac.account_type
, rp_ac.sortcode
, NVL(ovr_lmt.account_section_value,0) AS
account_section_value
, NVL(ovr_lmt.overlimit_amount,0) AS overlimit_amount1
, (NVL(ovr_lmt.overlimit_amount,0) - NVL(ovr_lmt.account_section_value,0)
) value_to_date
, (NVL(ovr_lmt.overlimit_amount,0) -
NVL(lmt_usg.limit_amount,0)
) amount_overlimit
, ovr_lmt.over_limit_id, NVL(lmt_usg.limit_amount,0) AS
limit_amount
, lmt_usg.period_type,lmt_usg.currency
FROM v_rp_bacs3day_service_user rp_bsu,
v_rp_bacs_service_office rp_bso,
v_rp_account rp_ac,
t_file fil,
t_over_limit ovr_lmt,
t_limit_usage lmt_usg
WHERE rp_bso.handling_bank_code = :p_scheme_member
AND rp_bsu.sponsoring_bank_code = rp_bso.owning_bank_code
AND rp_ac.service_user_number = rp_bsu.service_user_number
AND rp_bsu.service_user_number = fil.originator
AND fil.status <> 'R'
AND fil.processing_date = (SELECT cycle_date
FROM t_cycle
WHERE status = 1)
AND lmt_usg.account_id = rp_ac.account_id
AND ovr_lmt.limit_usage_id = lmt_usg.limit_usage_id
AND TO_CHAR (ovr_lmt.exceeded_date, 'DD-MM-YYYY') =
(SELECT TO_CHAR (TO_DATE (RTRIM (LTRIM (cycle_date)),
'YYDDD'),'DD-MM-YYYY')
FROM t_cycle
WHERE status = 1)
2.The hierarchy as per xsd that we need to define is :
<ServiceUserAccount>
<ServiceUser>
<Name></Name>
<Number></Number>
</ServiceUser> <SortCode></SortCode>
<AccountNumber></AccountNumber>
<NearOrOverLimitDetail>
<AccountType></AccountType>
<ProcessingDate></ProcessingDate>
..(there is a list of elements below it)
</NearOrOverLimitDetail>
</ServiceUserAccount>
In the xsd for the complex element type ServiceUser we need to display Service User Name and Number. For this I created a separate query Q2 in reports and joined it using data link with the parent Q1(which has data grouped on processing date) . So that it can be displayed as a separate element parallel to other elements like Sort code ,Account Numbers. But when we generate XML for this, then tags for Q2 query donot appear in xml.
And we get this hierarchy with missing Service User element
<ServiceUserAccount>
<SortCode></SortCode>
<AccountNumber></AccountNumber>
<NearOrOverLimitDetail>
<AccountType></AccountType>
<ProcessingDate></ProcessingDate>
..(there is a list of elements below it)
</NearOrOverLimitDetail>
</ServiceUserAccount>
Please let me know if you have any solution to implement this ASAP as its very urgent.
Thanks & Regds
Anuradha.Hi,
We are provided with XSD's for each report. Now we need to generate XML's from report that are as per the XSD's provided to us.
But the problem come's when we have to define hirearchies.
Like for example
1. Our Report is based on the following query:
SELECT DISTINCT '' as DUMMY
, fil.file_number
, TO_CHAR (TO_DATE (RTRIM (LTRIM (fil.processing_date)), 'YYDDD'),'DD-MM-YY') Processing_Dt
, rp_bsu.service_user_number
, rp_bsu.service_user_name
, rp_ac.account_number
, rp_ac.account_name
, rp_ac.account_type
, rp_ac.sortcode
, NVL(ovr_lmt.account_section_value,0) AS
account_section_value
, NVL(ovr_lmt.overlimit_amount,0) AS overlimit_amount1
, (NVL(ovr_lmt.overlimit_amount,0) - NVL(ovr_lmt.account_section_value,0)
) value_to_date
, (NVL(ovr_lmt.overlimit_amount,0) -
NVL(lmt_usg.limit_amount,0)
) amount_overlimit
, ovr_lmt.over_limit_id, NVL(lmt_usg.limit_amount,0) AS
limit_amount
, lmt_usg.period_type,lmt_usg.currency
FROM v_rp_bacs3day_service_user rp_bsu,
v_rp_bacs_service_office rp_bso,
v_rp_account rp_ac,
t_file fil,
t_over_limit ovr_lmt,
t_limit_usage lmt_usg
WHERE rp_bso.handling_bank_code = :p_scheme_member
AND rp_bsu.sponsoring_bank_code = rp_bso.owning_bank_code
AND rp_ac.service_user_number = rp_bsu.service_user_number
AND rp_bsu.service_user_number = fil.originator
AND fil.status <> 'R'
AND fil.processing_date = (SELECT cycle_date
FROM t_cycle
WHERE status = 1)
AND lmt_usg.account_id = rp_ac.account_id
AND ovr_lmt.limit_usage_id = lmt_usg.limit_usage_id
AND TO_CHAR (ovr_lmt.exceeded_date, 'DD-MM-YYYY') =
(SELECT TO_CHAR (TO_DATE (RTRIM (LTRIM (cycle_date)),
'YYDDD'),'DD-MM-YYYY')
FROM t_cycle
WHERE status = 1)
2.The hierarchy as per xsd that we need to define is :
<ServiceUserAccount>
<ServiceUser>
<Name></Name>
<Number></Number>
</ServiceUser> <SortCode></SortCode>
<AccountNumber></AccountNumber>
<NearOrOverLimitDetail>
<AccountType></AccountType>
<ProcessingDate></ProcessingDate>
..(there is a list of elements below it)
</NearOrOverLimitDetail>
</ServiceUserAccount>
In the xsd for the complex element type ServiceUser we need to display Service User Name and Number. For this I created a separate query Q2 in reports and joined it using data link with the parent Q1(which has data grouped on processing date) . So that it can be displayed as a separate element parallel to other elements like Sort code ,Account Numbers. But when we generate XML for this, then tags for Q2 query donot appear in xml.
And we get this hierarchy with missing Service User element
<ServiceUserAccount>
<SortCode></SortCode>
<AccountNumber></AccountNumber>
<NearOrOverLimitDetail>
<AccountType></AccountType>
<ProcessingDate></ProcessingDate>
..(there is a list of elements below it)
</NearOrOverLimitDetail>
</ServiceUserAccount>
Please let me know if you have any solution to implement this ASAP as its very urgent.
Thanks & Regds
Anuradha. -
MPOZ issue generating XMl file
Hi,
we have upgraded our ECC6 system to EHP5.Unfortunately one of the add-ons FI-CAX was not upgraded.
I want to generate XML file to upgrade this component.If I select EHP5 installation its picking up all the component which has already being upgraded.
Can you pls suggest how can I generate XML for one particular Add-on.
Thanks for your help in advance.
Regards!!
RaviHi Ravi,
As you said , ECC system EHP5 upgrade is finished but you need 1 add to upgrade seperatly now.
Pls ensure your system landscape , in SMSY of SolMan is updated correctly with upgrdaed component version for ECC.
Then try to download component via MOPZ , it sould auto calculate other latest vesrion to apply including your add on component.
Regards -
Generate xml of a rpd created by OBIEE Administration 11
I'm using this command "nqUDMLgen.exe -U Administrator -P Admin123 -R <location_to_rpd> -O <location_to_xml> -8" to generate xml for a rpd created by OBIEE Administration tool version 11. The error I get is "The repository <location_to_rpd> cannot be opened". But this works perfectly for a rpd created by version 10. I doubt in the username because the tools doesn't show the default username like that of version 10. What am I doing wrong?
This works for me
nqudmlgen.exe -P Admin123 -R C:\App11g\instances\instance3\bifoundation\OracleBIServerComponent\coreapplication_obis1\repository\SampleAppLite_BI0001.rpd -O one1.udml -8
If it is helpful, please mark as correct or helpful -
Generate xml form retrieved query...
HI,
To start with am working to generate xml programatically for the first time ,I'd appreciate if anybody could help me out on the following...
I have some records in the database and am supposed to generate an xml file from the retrieved query and store the xml in a specific location.
iam using DOM parser to write the xml file.
Please let me know as of what is the classpath that i should set and what i need to compile my class
How can i generate the required xml file.
Thanks in advance...
Great day ahead....hi thans for the code and after writing the folloing code am getting the erros as
I had set my classpath to Jdom.jar and compiled and got this error...can u let me know the classpath that i have to set????
i think it is the problem with only classpath( if am thinking right)......
location: class com.Fortune.adminusers.AdminUsers
Element root = new Element("top");
^
src\Admin\AdminUsers.java:48: cannot resolve symbol
symbol : class Element
location: class com.Fortune.adminusers.AdminUsers
Element root = new Element("top");
^
src\Admin\AdminUsers.java:53: cannot resolve symbol
symbol : class Element
location: class com.Fortune.adminusers.AdminUsers
Element next = new Element("next");
^
src\Admin\AdminUsers.java:53: cannot resolve symbol
symbol : class Element
location: class com.Fortune.adminusers.AdminUsers
Element next = new Element("next");
^
src\Admin\AdminUsers.java:56: cannot resolve symbol
symbol : variable Format
location: class com.Fortune.adminusers.AdminUsers
XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
^
------------------------Code Sample-----------------------------------------------
import java.sql.*;
import <app packages>
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.DOMBuilder;
import org.jdom.output.XMLOutputter;
public class <XXXXXXX>
private DBC dbConnector = null;
public Users getUsers(String loginid)
Users user = null;
ResultSet rs_users=null;
Statement get_users=null;
Connection conn=null;
try
String query_select_user = "";
query_select_user = <Database Query>
conn = dbConnector.getConnection();
get_users = conn.createStatement();
rs_users = get_users.executeQuery(query_select_user);
if((rs_users != null) && (rs_users.next()))
do
user = new Users();
user.setMainMod(rs_users.getString("MainModuleId"));
user.setModDesc(rs_users.getString("ModuleDesc"));
String top = user.getMainMod();
Element root = new Element("top");
root.setText(top);
String child = user.getModDesc();
System.out.println(top);
System.out.println(child);
Element next = new Element("next");
next.setText(child);
Document doc = new Document(root);
XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
OutputStream out = new FileOutputStream("1.xml");
writer.output(doc, out);
writer.output(doc, System.out);
}while(rs_users.next());
}catch (Exception e) {e.printStackTrace();}
finally
try
if ( rs_users != null)
rs_users.close();
if(get_users!=null)
get_users.close();
if(conn!=null)
conn.close();
}catch (SQLException se){}
return user;
}
Maybe you are looking for
-
Preview bug, not responding to key strokes in full screen view immediately
I've had leopard since it was released and have been very pleased with it for the most part. I update the software regularly. My problem is that since moving to leopard I cannot use the arrow keys (being the primary ones that I use) immediately upon
-
I am using OSX 10.9.5, and Keynote 6.2.2 running on it. Now it says that to open a document Icreated in that version of keynote on that system, I need to upgrade the OS AND Keynote. This is outrageous! I want to take my time upgrading the OS, and Ke
-
Does not recognize bootable usb
My HP laptop does not recognize some bootable usb devices in the boot menu. I have a HP tower and the laptop in my office and the tower will recognize and boot the a USB device that the laptop will not recognize in the boot menu. Laptop: HP Pavilion
-
HT201343 MacBook Pro & Apple TV
have an apple TV. My MacBook Pro sees the apple TV in iTunes, but no where else. how can i see my desktop on my apple TV?
-
Hi Guys I would like to have an image slider (with each image the same grey gradient background but different foreground) on my website in the banner: www.bmgraphics.be Which one would be best, and what are the do's and don'ts? I've seen this templat