Nested XML output in relational format
I have serious performance issue in converting the relational xml in to relational table.
Below is my query which works good if number of nodes are around <100.
I have issue if number of node is more then 500.I have requirement where the number of nodes can be >5000.
I am using Oracle 11g R2.
Appreciate the help in tuning this or any alternative for this.
Thanks,
WITH t1
AS (SELECT xmltype('<Id_359328 prodId="101265" prodName="Computer">
<Id_359329 prodId="101788" prodName="C1">
<Id_359330 prodId="175" prodName="C2"/>
<Id_359331 prodId="101766" prodName="C3"/>
</Id_359329>
<Id_388909 prodId="100654" prodName="C4"/>
<Id_388191 prodId="100672" prodName="C5"/>
<Id_388927 prodId="100625" prodName="C6"/>
<Id_359332 prodId="101766" prodName="C7">
<Id_359380 prodId="100651" prodName="C8" />
<Id_359334 prodId="100643" prodName="C9">
<Id_359337 prodId="101788" prodName="C10">
<Id_359338 prodId="175" prodName="C11"/>
<Id_359339 prodId="101766" prodName="C12"/>
</Id_359337>
</Id_359334>
<Id_359336 prodId="101860" prodName="C13"/>
</Id_359332>
</Id_359328>')
t1_val
FROM DUAL)
SELECT ROWNUM rn, id, prod_id, prnt_id
FROM t1,
XMLTABLE ('for $i in $doc/descendant::*
return <ROW><Id>{name($i)}</Id>
<PROD_ID>{data($i/@prodId)}</PROD_ID>
<PRNT_ID>{name($i/..)}</PRNT_ID>
</ROW>'
PASSING t1.t1_val AS "doc"
COLUMNS id VARCHAR2 (100) PATH '/ROW/Id',
prod_id NUMBER PATH '/ROW/PROD_ID',
prnt_id VARCHAR2 (100) PATH '/ROW/PRNT_ID'
ORDER BY ROWNUM
Output
RN ID PROD_ID PRNT_ID
1 Id_359328 101265
2 Id_359329 101788 Id_359328
3 Id_359330 175 Id_359329
4 Id_359331 101766 Id_359329
5 Id_388909 100654 Id_359328
6 Id_388191 100672 Id_359328
7 Id_388927 100625 Id_359328
8 Id_359332 101766 Id_359328
9 Id_359380 100651 Id_359332
10 Id_359334 100643 Id_359332
11 Id_359337 101788 Id_359334
12 Id_359338 175 Id_359337
13 Id_359339 101766 Id_359337
14 Id_359336 101860 Id_359332Edited by: ravit on Apr 20, 2010 4:43 PM
Hi,
I agree with damorgan, XQuery processing requires some ressources and it could help to have some of your system specs and settings.
Anyway, tuning is not my specialty but I can give you an alternative.
You could move the XQuery logic to an XSLT stylesheet and transform the document before passing it to XMLTable.
For example :
Creating sample data like yours...
CREATE TABLE test_tree AS
SELECT n,
power(10,p)*(1+trunc(n/power(10,p))) p
FROM (
SELECT level n,
nvl(length(regexp_substr(level,'0+$')),0)+1 p
FROM dual
CONNECT BY level < 10000
UNION ALL
SELECT 10000, null FROM dual
CREATE TABLE test_xml (
doc1 xmltype,
doc2 xmltype
DECLARE
ctx dbms_xmlgen.ctxHandle;
doc xmltype;
xsl xmltype := xmltype(
'<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="*">
<ROW Id="{name(.)}">
<PROD_ID><xsl:value-of select="@prodId"/></PROD_ID>
<PRNT_ID><xsl:value-of select="name(..)"/></PRNT_ID>
</ROW>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>'
BEGIN
-- hierarchical XML generation :
ctx := dbms_xmlgen.newContextFromHierarchy(
'select level,
xmlelement(evalname(''Id_''||to_char(n,''fm09999'')),
xmlattributes( to_char(n) as "prodId",
''C''||to_char(n) as "prodName" )
from test_tree
connect by prior n = p
start with p is null'
doc := dbms_xmlgen.getXMLType(ctx);
dbms_xmlgen.closeContext(ctx);
INSERT INTO test_xml VALUES(doc, doc.transform(xsl));
COMMIT;
END;
/Now, TEST_XML.DOC1 holds the original document, DOC2 holds the result of the transformation :
<root>
<ROW Id="Id_10000">
<PROD_ID>10000</PROD_ID>
<PRNT_ID>#document</PRNT_ID>
</ROW>
<ROW Id="Id_01000">
<PROD_ID>1000</PROD_ID>
<PRNT_ID>Id_10000</PRNT_ID>
</ROW>
<ROW Id="Id_00100">
<PROD_ID>100</PROD_ID>
<PRNT_ID>Id_01000</PRNT_ID>
</ROW>
<ROW Id="Id_00010">
<PROD_ID>10</PROD_ID>
<PRNT_ID>Id_00100</PRNT_ID>
</ROW>
<ROW Id="Id_09997">
<PROD_ID>9997</PROD_ID>
<PRNT_ID>Id_10000</PRNT_ID>
</ROW>
<ROW Id="Id_09998">
<PROD_ID>9998</PROD_ID>
<PRNT_ID>Id_10000</PRNT_ID>
</ROW>
<ROW Id="Id_09999">
<PROD_ID>9999</PROD_ID>
<PRNT_ID>Id_10000</PRNT_ID>
</ROW>
</root>Then we can execute the query on DOC2:
SELECT rn, id, prod_id, prnt_id
FROM test_xml x,
XMLTable(
'/root/ROW'
passing x.doc2
columns
id VARCHAR2(100) path '@Id',
prod_id NUMBER path 'PROD_ID',
prnt_id VARCHAR2(100) path 'PRNT_ID',
rn FOR ORDINALITY
;On my environment, 10000 records fetched in about 18s.
Similar Messages
-
Hi,
I have created a rdf, concurrent program with output as "XML".
When i created the template i updated the "Preview Option as Excel".
But when i run the con program the output shows as PDF.
Can i have solution as to get the output in EXCEL format.
(I dont want to change the option from PDFto EXCEL when i submit the request to run the program as the user is not comfortable doing so)
Thanks in advance.Check this note.
Note: 401328.1 - Default Layout Format for XML Publisher Concurrent Request Is Always PDF
https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=401328.1 -
Nested XML Output in PL/SQL
I need to generate XML that looks like this:
<Person>
<Name>
<FirstName>IMA</FirstName>
<MiddleName>ANOTHER</MiddleName>
<LastName>TEST</LastName>
<BirthDate>04/05/1982</BirthDate>
</Name>
<IDDetails>
<SSNID>234-23-3333</SSNID>
<OtherID>19781</OtherID>
</IDDetails>
<PhysicalDetails>
<Weight>145</Weight>
<EyeColor>BLUE</EyeColor>
<HairColor></HairColor>
<Sex>FEMALE</Sex>
<Race>BLACK</Race>
<SkinToneText></SkinTone>
</PhysicalDetails>
<SocialDetails>
<Ethnicity>UNKNOWN</Ethnicity>
<Language>ENGLISH</Language>
</SocialDetails>
<Address>
<Street>123 Somewhere Street</Street>
<City>AnyWhere</City>
<State>Confusion</State>
<Zip>99999</Zip>
</Address>
</Person>
I was able to sucessfully generate it in SQL by creating a view using this code:
create or replace view person_xml_view as
select
xmlelement("Person",
xmlelement("Name",
xmlelement("FirstName", first_name),
xmlelement("MiddleName",middle_name),
xmlelement("LastName",last_name),
xmlelement("BirthDate",to_char(date_of_birth,''MM/DD/YYYY''))),
xmlelement("IDDetails",
xmlelement("SSN",b.external_number),
xmlelement("OtherID",a.mni)),
xmlelement("PhysicalDetails",
xmlelement("Weight",a.weight),
xmlelement("EyeColor",a.eye_color),
xmlelement("HairColor",a.hair_color),
xmlelement("Sex",a.sex),
xmlelement("Race",a.race),
xmlelement("SkinTone",a.skin_tone)),
xmlelement("SocialDetails",
xmlelement("Ethnicity",ethnicity),
xmlelement("Language",language)),
xmlelement("Address",
xmlelement("Street",c.address),
xmlelement("City",c.city),
xmlelement("State",c.state),
xmlelement("Zip",c.zip)))
as result from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = 'SOCIAL SECURITY NUMBER') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= 'T') AND
a.MNI = 19781);
My end goal is to write a function that returns the XML back to the caller, but when I the dbms_xmlgen I can't get the sub-tags to be inserted correctly. Here's the code as it is today:
FUNCTION GETXML
( v_pk IN Number)
RETURN xmltype as out xmltype;
ctx dbms_xmlgen.ctxhandle;
BEGIN
ctx := dbms_xmlgen.newcontext('select a.first_name as "FirstName",
a.middle_name as "MiddleName",
a.last_name as "LastName",
to_char(a.date_of_birth,''MM/DD/YYYY'') AS "BirthDate",
b.external_number as "SSNID",
a.mni as "OtherID",
a.weight as "Weight",
a.eye_color as "EyeColor",
a.hair_color as "HairColor",
a.sex as "Sex",
a.race as "Race",
a.skin_tone as "SkinTone",
a.ethnicity as "Ethnicity",
a.language as "Language",
c.address as "Street",
c.city as "City",
c.state as "State",
c.zip as "Zip"
from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = ''SOCIAL SECURITY NUMBER'') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= ''T'') AND
a.MNI = '||V_MNI);
dbms_xmlgen.setrowsettag(ctx,'Person');
dbms_xmlgen.setrowtag(ctx,'Name');
dbms_xmlgen.setrowtag(ctx,'IDDetails');
dbms_xmlgen.setrowtag(ctx,'PhysicalDetails');
dbms_xmlgen.setrowtag(ctx,'SocialDetails');
dbms_xmlgen.setrowtag(ctx,'Address');
out := dbms_xmlgen.getxmltype(ctx);
dbms_xmlgen.closecontext(ctx);
return out;
END;
How do you do the nested tags?Hi,
Here is simple way of genrating nested XML.
FUNCTION GETXML
( v_pk IN Number)
RETURN sys.XMLType
CURSOR C1
IS
xmlelement("Person",
xmlelement("Name",
xmlforest(first_name as "FirstName",
middle_name as "MiddleName",
last_name as "LastName",
to_char(date_of_birth,''MM/DD/YYYY'') as"BirthDate"),
xmlelement("IDDetails",
xmlforest(b.external_number as "SSN",
a.mni as "OtherID")),
xmlelement("PhysicalDetails",
xmlforest(a.weight as "Weight",
a.eye_color as "EyeColor",
a.hair_color as "HairColor",
a.sex as "Sex",
a.race as "Race",
a.skin_tone as "SkinTone")),
xmlelement("SocialDetails",
xmlforest(ethnicity as "Ethnicity",
language as "Language")),
xmlelement("Address",
xmlforest(c.address as "Street",
c.city as "City",
c.state as "State",
c.zip as "Zip")) as result
from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = 'SOCIAL SECURITY NUMBER') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= 'T') AND
a.MNI = 19781);
v_xml sys.XMLType
BEGIN
open c1;
fetch c1 into v_xml;
close c1;
return v_xml;
END
In short use xmlforest to genrate inner child tags. -
How can print blank rows for XML output report..
Hi all,
I am working in XML output PO fix format report and in that report there is 3 sections. (1) Header section(2)Line section (3) Footer section. My requirement is like this, header and footer section print in all pages and line section break for next page after printing fix 15 lines in a page. And if any page has less then 15 lines then it generate remaining blank row to maintain footer position.
Please suggest me, how can i generate blank rows and break lines for page if there is more then 15 rows in Line section.
Thanks in Advance!Hi,
<?for-each:ROW?>
<?end for-each?><xsl:variable name="cnt" select="count(//row|//ROW)" />
<?for-each:xdoxslt:foreach_number($_XDOCTX,1,15-count(ROW),1)?> <?end if?>
this will create 15 lines irrespective of you have that much rows of data in xml or not
if you want more help , drop me mail @ [email protected] -
XML Report is generating xml output instead of pdf output
Hi All,
I have created a report using BI publisher.When I am runnng the report it is showing xml output instaead of pdf format...The report is getting completed with a warning message.I am able to see other reports (XML) outputs in pdf format.But this report is having some problem ,which i am not able to identify.
Please help..
Thanks,
JoohiOutput of OPP log file
[5/17/12 5:35:11 PM] [main] Starting GSF service with concurrent process id = 457384.
[5/17/12 5:35:11 PM] [main] Initialization Parameters: oracle.apps.fnd.cp.opp.OPPServiceThread:2:0:max_threads=5
[5/17/12 5:35:11 PM] [Thread-32] Service thread starting up.
[5/17/12 5:35:11 PM] [Thread-33] Service thread starting up.
[5/17/12 5:47:20 PM] [OPPServiceThread0] Post-processing request 33169846.
[5/17/12 5:47:21 PM] [457384:RT33169846] Executing post-processing actions for request 33169846.
[5/17/12 5:47:21 PM] [457384:RT33169846] Starting XML Publisher post-processing action.
[5/17/12 5:47:21 PM] [457384:RT33169846]
Template code: XXMI_MILEAGE_ALLOWANCE
Template app: XXMI
Language: en
Territory: 00
Output type: PDF
[051712_054721299][][EXCEPTION] [DEBUG] ------- Preferences defined PreferenceStore -------
[051712_054721299][][EXCEPTION] [DEBUG] ------- Environment variables stored in EnvironmentStore -------
[051712_054721299][][EXCEPTION] [DEBUG] [FND_JDBC_IDLE_THRESHOLD.LOW]:[-1]
[051712_054721299][][EXCEPTION] [DEBUG] [SECURITY_GROUP_ID]:[0]
[051712_054721299][][EXCEPTION] [DEBUG] [FND_JDBC_BUFFER_DECAY_INTERVAL]:[300]
[051712_054721299][][EXCEPTION] [DEBUG] [NLS_CHARACTERSET]:[AL32UTF8]
[051712_054721300][][EXCEPTION] [DEBUG] [RESP_APPL_ID]:[-1]
[051712_054721300][][EXCEPTION] [DEBUG] [NLS_LANGUAGE]:[AMERICAN]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_JDBC_BUFFER_MIN]:[1]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_JDBC_BUFFER_MAX]:[2]
[051712_054721300][][EXCEPTION] [DEBUG] [NLS_NUMERIC_CHARACTERS]:[.,]
[051712_054721300][][EXCEPTION] [DEBUG] [APPS_JDBC_URL]:[jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=ffebdbs04.datahost.int)(PORT=1611)))(CONNECT_DATA=(SID=MFDEV)))]
[051712_054721300][][EXCEPTION] [DEBUG] [RESP_ID]:[-1]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_MAX_JDBC_CONNECTIONS]:[500]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_JDBC_USABLE_CHECK]:[false]
[051712_054721300][][EXCEPTION] [DEBUG] [USER_ID]:[-1]
[051712_054721300][][EXCEPTION] [DEBUG] [NLS_TERRITORY]:[AMERICA]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_JDBC_PLSQL_RESET]:[false]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_JDBC_CONTEXT_CHECK]:[true]
[051712_054721300][][EXCEPTION] [DEBUG] [NLS_DATE_FORMAT]:[DD-MON-RR]
[051712_054721300][][EXCEPTION] [DEBUG] [FND_JDBC_BUFFER_DECAY_SIZE]:[5]
[051712_054721301][][EXCEPTION] [DEBUG] [FND_JDBC_IDLE_THRESHOLD.HIGH]:[-1]
[051712_054721301][][EXCEPTION] [DEBUG] [NLS_SORT]:[BINARY]
[051712_054721301][][EXCEPTION] [DEBUG] [NLS_DATE_LANGUAGE]:[AMERICAN]
[051712_054721301][][EXCEPTION] [DEBUG] [LOGIN_ID]:[-1]
[051712_054721301][][EXCEPTION] [DEBUG] ------- Properties stored in Java System Properties -------
[051712_054721301][][EXCEPTION] [DEBUG] [APPLTMP]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/appltmp]
[051712_054721301][][EXCEPTION] [DEBUG] [java.runtime.name]:[Java(TM) SE Runtime Environment]
[051712_054721301][][EXCEPTION] [DEBUG] [sun.boot.library.path]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/i386]
[051712_054721301][][EXCEPTION] [DEBUG] [java.vm.version]:[16.0-b13]
[051712_054721301][][EXCEPTION] [DEBUG] [OVERRIDE_DBC]:[true]
[051712_054721301][][EXCEPTION] [DEBUG] [dbcfile]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/appl/fnd/12.0.0/secure/MFDEV.dbc]
[051712_054721301][][EXCEPTION] [DEBUG] [java.vm.vendor]:[Sun Microsystems Inc.]
[051712_054721301][][EXCEPTION] [DEBUG] [java.vendor.url]:[http://java.sun.com/]
[051712_054721301][][EXCEPTION] [DEBUG] [path.separator]:[:]
[051712_054721301][][EXCEPTION] [DEBUG] [APPLCSF]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/logs/appl/conc]
[051712_054721301][][EXCEPTION] [DEBUG] [java.vm.name]:[Java HotSpot(TM) Server VM]
[051712_054721302][][EXCEPTION] [DEBUG] [file.encoding.pkg]:[sun.io]
[051712_054721302][][EXCEPTION] [DEBUG] [sun.java.launcher]:[SUN_STANDARD]
[051712_054721302][][EXCEPTION] [DEBUG] [user.country]:[US]
[051712_054721302][][EXCEPTION] [DEBUG] [sun.os.patch.level]:[unknown]
[051712_054721302][][EXCEPTION] [DEBUG] [java.vm.specification.name]:[Java Virtual Machine Specification]
[051712_054721302][][EXCEPTION] [DEBUG] [user.dir]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/logs/appl/conc/log]
[051712_054721302][][EXCEPTION] [DEBUG] [java.runtime.version]:[1.6.0_18-b07]
[051712_054721302][][EXCEPTION] [DEBUG] [CLIENT_PROCESSID]:[30695]
[051712_054721302][][EXCEPTION] [DEBUG] [java.awt.graphicsenv]:[sun.awt.X11GraphicsEnvironment]
[051712_054721302][][EXCEPTION] [DEBUG] [java.endorsed.dirs]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/endorsed]
[051712_054721302][][EXCEPTION] [DEBUG] [os.arch]:[i386]
[051712_054721302][][EXCEPTION] [DEBUG] [JTFDBCFILE]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/appl/fnd/12.0.0/secure/MFDEV.dbc]
[051712_054721302][][EXCEPTION] [DEBUG] [java.io.tmpdir]:[tmp]
[051712_054721302][][EXCEPTION] [DEBUG] [line.separator]:[
[051712_054721303][][EXCEPTION] [DEBUG] [java.vm.specification.vendor]:[Sun Microsystems Inc.]
[051712_054721303][][EXCEPTION] [DEBUG] [os.name]:[Linux]
[051712_054721303][][EXCEPTION] [DEBUG] [FND_JDBC_BUFFER_MIN]:[1]
[051712_054721303][][EXCEPTION] [DEBUG] [cpid]:[457384]
[051712_054721303][][EXCEPTION] [DEBUG] [sun.jnu.encoding]:[UTF-8]
[051712_054721303][][EXCEPTION] [DEBUG] [oracle.apps.fnd.common.Pool.leak.mode]:[stderr:off]
[051712_054721303][][EXCEPTION] [DEBUG] [java.library.path]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/i386/server:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/i386:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/../lib/i386:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/lib32:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/lib:/u02/erp/mfdevAPP/apps/apps_st/appl/cz/12.0.0/bin:/u02/erp/mfdevAPP/apps/apps_st/appl/iby/12.0.0/bin:/u02/erp/mfdevAPP/apps/apps_st/appl/pon/12.0.0/bin:/u02/erp/mfdevAPP/apps/apps_st/appl/sht/12.0.0/lib:/usr/java/packages/lib/i386:/lib:/usr/lib]
[051712_054721303][][EXCEPTION] [DEBUG] [java.specification.name]:[Java Platform API Specification]
[051712_054721303][][EXCEPTION] [DEBUG] [java.class.version]:[50.0]
[051712_054721303][][EXCEPTION] [DEBUG] [sun.management.compiler]:[HotSpot Tiered Compilers]
[051712_054721303][][EXCEPTION] [DEBUG] [queue_appl_id]:[0]
[051712_054721303][][EXCEPTION] [DEBUG] [os.version]:[2.6.18-238.12.1.0.1.el5]
[051712_054721303][][EXCEPTION] [DEBUG] [LONG_RUNNING_JVM]:[true]
[051712_054721303][][EXCEPTION] [DEBUG] [user.home]:[home/appmfdev]
[051712_054721304][][EXCEPTION] [DEBUG] [user.timezone]:[Europe/Berlin]
[051712_054721304][][EXCEPTION] [DEBUG] [java.awt.printerjob]:[sun.print.PSPrinterJob]
[051712_054721304][][EXCEPTION] [DEBUG] [file.encoding]:[UTF-8]
[051712_054721304][][EXCEPTION] [DEBUG] [java.specification.version]:[1.6]
[051712_054721304][][EXCEPTION] [DEBUG] [CACHEMODE]:[DISTRIBUTED]
[051712_054721304][][EXCEPTION] [DEBUG] [conc_queue_id]:[6269]
[051712_054721304][][EXCEPTION] [DEBUG] [java.class.path]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/lib/dt.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/lib/tools.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/rt.jar:/u02/erp/mfdevAPP/apps/apps_st/comn/java/lib/appsborg2.zip:/u02/erp/mfdevAPP/apps/apps_st/comn/java/classes]
[051712_054721304][][EXCEPTION] [DEBUG] [user.name]:[appmfdev]
[051712_054721304][][EXCEPTION] [DEBUG] [DBCFILE]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/appl/fnd/12.0.0/secure/MFDEV.dbc]
[051712_054721304][][EXCEPTION] [DEBUG] [java.vm.specification.version]:[1.0]
[051712_054721304][][EXCEPTION] [DEBUG] [java.home]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre]
[051712_054721304][][EXCEPTION] [DEBUG] [sun.arch.data.model]:[32]
[051712_054721304][][EXCEPTION] [DEBUG] [user.language]:[en]
[051712_054721304][][EXCEPTION] [DEBUG] [java.specification.vendor]:[Sun Microsystems Inc.]
[051712_054721304][][EXCEPTION] [DEBUG] [java.vm.info]:[mixed mode]
[051712_054721305][][EXCEPTION] [DEBUG] [logfile]:[u02/erp/mfdevAPP/inst/apps/MFDEV_ffebapp04/logs/appl/conc/log/FNDOPP457384.txt]
[051712_054721305][][EXCEPTION] [DEBUG] [java.version]:[1.6.0_18]
[051712_054721305][][EXCEPTION] [DEBUG] [java.ext.dirs]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/ext:/usr/java/packages/lib/ext]
[051712_054721305][][EXCEPTION] [DEBUG] [sun.boot.class.path]:[u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/resources.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/rt.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/sunrsasign.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/jsse.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/jce.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/charsets.jar:/u02/erp/mfdevAPP/apps/tech_st/10.1.3/appsutil/jdk/jre/classes]
[051712_054721305][][EXCEPTION] [DEBUG] [java.vendor]:[Sun Microsystems Inc.]
[051712_054721305][][EXCEPTION] [DEBUG] [FND_JDBC_BUFFER_MAX]:[2]
[051712_054721305][][EXCEPTION] [DEBUG] [file.separator]:[]
[051712_054721305][][EXCEPTION] [DEBUG] [java.vendor.url.bug]:[http://java.sun.com/cgi-bin/bugreport.cgi]
[051712_054721305][][EXCEPTION] [DEBUG] [sun.io.unicode.encoding]:[UnicodeLittle]
[051712_054721305][][EXCEPTION] [DEBUG] [sun.cpu.endian]:[little]
[051712_054721305][][EXCEPTION] [DEBUG] [APPLOUT]:[out]
[051712_054721305][][EXCEPTION] [DEBUG] [sun.cpu.isalist]:[]
[5/17/12 5:47:23 PM] [UNEXPECTED] [457384:RT33169846] java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.apps.xdo.common.xml.XSLT10gR1.invokeNewXSLStylesheet(XSLT10gR1.java:558)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:228)
at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:177)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1044)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:997)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:212)
at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1665)
at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:975)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.runProcessTemplate(TemplateHelper.java:5936)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3459)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3548)
at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:285)
at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:173)
Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'ref' used but not declared.
at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)
... 17 more
[5/17/12 5:47:23 PM] [457384:RT33169846] Completed post-processing actions for request 33169846.
[GC 21325K->4165K(63360K), 0.0107770 secs] -
XML Publisher report default output in Excel format.
Hi,
We have defined one concurrent program whose output format is text, this concurrent program executable is PL/SQL and in this PL/SQL program we are generating XML data and displaying XML using below fnd_request.
l_conc_id := FND_REQUEST.SUBMIT_REQUEST('GMP','GMPPDROP','', '',FALSE,
p_sequence_num,chr(0),'','','','','','','','','','','',
We have also defined template for this.
Using below fnd_request we are choosing template and data is getting generated in PDF format. Now our requirement is to display the output by default in Excel format.
FND_REQUEST.SUBMIT_REQUEST('XDO','XDOREPPB','', '',FALSE,'',
l_conc_id,554,G_comb_pdr_temp,
G_comb_pdr_locale,'Y','RTF','',scale_report,'','','','','',
When i saw XML Report Publisher concurrent program, there is one parameter for Output Format and i tried passing 'Excel'/EXCEL/excel to this parameter but output is still coming in PDF format.
FND_REQUEST.SUBMIT_REQUEST('XDO','XDOREPPB','', '',FALSE,'',
l_conc_id,554,G_comb_pdr_temp,
G_comb_pdr_locale,'Y','RTF','Excel',scale_report,'','','','','',
I have also tried giving Default Output to EXCEL in template definition but this is also not working.
Your valuable suggestions highly appreciated.
Thanks
VijayHi;
What is EBS version? Please see below which could be helpful for your issue:
Changing Output Format to RTF or Excel in XML Publisher Request Does Not Display Output Correctly [ID 404512.1]
Cannot View BI Publisher (formerly XML Publisher) Report Output In Excel Format or XHTML [ID 359875.1
How is Default Output Type Determined for Reports Submitted Using XML [ID 888972.1]
Also see:
XML PUBLISHER report in Excel out put problem
XML PUBLISHER report in Excel out put problem
Regard
Helios -
Xml report output in excel format without using options tab in EBS
How to get xml publisher report output in excel format without using options tab in EBS?
I am getting XML Publisher report output in excel format by using options tab while submitting the concurrent request .
But i want to get excel output automatically.
Can anyone give idea to get XML publisher Report output in excel without selecting options tab.
Thanks in advance
Sandeep VHey Sandeep,
I am working on a similar format for a report and if possible can you please give me some guidelines. I have initially created reports using XML Publisher, but for those , the output preview format was PDF. So, if I select the preview format as EXCEL will it give me output in Excel and for this to happen, how do I define the rtf template. I believe the working will be same as for PDF, create a rdf report, get output in XML and apply the template to get the data in Excel or there is something different to this.
Thanks,
Sunil -
Xml output format in sql*plus problem
Hi all,
In stead of seeing xml output in multiple line format, my sql*plus always returns xml output in ONE line, is there a way to change the format, it's really hard to read.
Thanks
1 select xmlelement("row", xmlelement("user", xmlattributes(username as "name", default_tablespa
2 from dba_users
3* where rownum=1
SQL>/
XMLELEMENT("ROW",XMLELEMENT("USER",XMLATTRIBUTES(USERNAMEAS"NAME",DEFAULT_TABLES
<row><user name="SYS" tbs="SYSTEM"></user></row>
however I want to see something well formatted like
<row>
<user name="SYS" tbs="SYSTEM"></user>
</row>Not sure if there are any settings with the SQL*PLUS but if you use packages other than the SQLX operators like DBMS_XMLQUERY, DBMS_XMLGEN, SYS_XMLGEN to generate xml then the output is as desired.
select dbms_xmlgen.getxml('select username, default_tablespace from dba_users
where rownum=1') from dual
DBMS_XMLGEN.GETXML('SELECTUSERNAME,DEFAULT_TABLESPACEFROMDBA_USERSWHEREROWNUM=1'
<?xml version="1.0"?>
<ROWSET>
<ROW>
<USERNAME>REVIEW</USERNAME>
<DEFAULT_TABLESPACE>METRICS</DEFAULT_TABLESPACE>
</ROW>
</ROWSET>
But these packages does not offer the flexibility you have with SQLX operators.
so if you requirement is simple generation you can use the above method. -
How can I format the XML output I get from extract()?
- get rid of new lines
- get rid of indents
- get rid of namespaces
Thanks.You write some PL/SQL or Java code yourself to do so. We'll provide the capability to turn off the indent & newline stuff in a future release. I'm at a loss to understand why you would want to turn off namespace declarations though--they change the semantics of the data.
-
Add attributes of dataTemplate, custom format, xml output
I need to format dataTemplate tag, in xml-output.
E.g.
<myDataTemplate_tag_name SchemaVersion="1.0" xmlns="http://www.oracle.com/">
Now, I have in xml
<dataTemplate name="myDataTemplate_tag_name" defaultPackage="ccc_pack" version="1.0" description='SchemaVersion=\"1.0\" xmlns=\"http://www.oracle.com/\"'>
but not work.
Any suggestion? How can I add attributes?
Thanks.
kale.
Edited by: kaleonardo on Oct 22, 2009 3:02 AM
Edited by: kaleonardo on Oct 22, 2009 7:12 AMI discovered, I can make a xsl-xml template for manipulating tag name and attribute.
Now, my problem is to keep all informations which are in main tag.
Eg.
my xml:
<?xml version="1.0" encoding="UTF-8" ?>
<InsNewArrival>
<InsCodeVersions>
<CountryVer>2007</CountryVer>
<EuCountryVer>2007</EuCountryVer>
<CnVer>2008</CnVer>
<ModeOfTransportVer>2005</ModeOfTransportVer>
<DeliveryTermsVer>2005</DeliveryTermsVer>
<NatureOfTransactionAVer>2005</NatureOfTransactionAVer>
<NatureOfTransactionBVer>2005</NatureOfTransactionBVer>
<CountyVer>1</CountyVer>
<LocalityVer>06/2006</LocalityVer>
<UnitVer>1</UnitVer>
</InsCodeVersions>
</InsNewArrival>
after xsl
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="InsNewArrival/*">
<InsNewArrival>
<xsl:attribute name="SchemaVersion">1.0</xsl:attribute>
</InsNewArrival>
</xsl:template>
</xsl:stylesheet>
I have
<?xml version="1.0" encoding="UTF-8" ?>
<InsNewArrival SchemaVersion="1.0" />
not
<?xml version="1.0" encoding="UTF-8" ?>
<InsNewArrival SchemaVersion="1.0" xmlns="http://www.intrastat.ro/xml/InsSchema">
<InsCodeVersions>
<CountryVer>2007</CountryVer>
<EuCountryVer>2007</EuCountryVer>
<CnVer>2008</CnVer>
<ModeOfTransportVer>2005</ModeOfTransportVer>
<DeliveryTermsVer>2005</DeliveryTermsVer>
<NatureOfTransactionAVer>2005</NatureOfTransactionAVer>
<NatureOfTransactionBVer>2005</NatureOfTransactionBVer>
<CountyVer>1</CountyVer>
<LocalityVer>06/2006</LocalityVer>
<UnitVer>1</UnitVer>
</InsCodeVersions>
</InsNewArrival>
Thanks.
kale -
XML Output with nesting of group
Hi,
Not sure if this is even possible to resolve but I figured I might as well ask.
I have a report which is built using a Reference Cursor which outputs to XML. The data is coming back exactly as expected so I am happy that the cursor is working.
I am now moving into trying to make the report a bit more advanced.
My aim is to get the XML output looking like:
<?xml version="1.0" encoding="WINDOWS-1252"?>
<!-- Generated by Oracle Reports version 9.0.2.0.3 -->
<TEST1>
<STANDARD1>
<IDENTIFIER>000005385/7743198743</IDENTIFIER>
<RUNDATE>21-AUG-09</RUNDATE>
<TABLE1>
<TABLE1_FIELD1>000708</TABLE1_FIELD1>
<TABLE1_FIELD2>ABCDEF</TABLE1_FIELD2>
<TABLE1_FIELD3>123456</TABLE1_FIELD3>
</TABLE1>
<TABLE2>
<TABLE2_FIELD1>Happy</TABLE2_FIELD1>
<TABLE2_FIELD2>Days</TABLE2_FIELD2>
<TABLE2_FIELD3>Are Here</TABLE2_FIELD3>
</TABLE2>
</STANDARD1>
</TEST1>
At the moment the best that I can seem to do is the following using Break Groups.
<?xml version="1.0" encoding="WINDOWS-1252"?>
<!-- Generated by Oracle Reports version 9.0.2.0.3 -->
<TEST>
<STANDARD1>
<IDENTIFIER>000005385/7743198743</IDENTIFIER>
<RUNDATE>21-AUG-09</RUNDATE>
<TABLE1>
<TABLE1_FIELD1>000708</TABLE1_FIELD1>
<TABLE1_FIELD2>ABCDEF</TABLE1_FIELD2>
<TABLE1_FIELD3>123456</TABLE1_FIELD3>
<TABLE2>
<TABLE2_FIELD1>Happy</TABLE2_FIELD1>
<TABLE2_FIELD2>Days</TABLE2_FIELD2>
<TABLE2_FIELD3>Are Here</TABLE2_FIELD3>
</TABLE2>
</TABLE1>
</STANDARD1>
</TEST>
So the Table2 tags are a child of the Table1 grouping. In reality the table2 information should be at the same level as table1.
Is there anyway in Oracle Reports where you can create the equivilant of a break group but allow multiple groups to have the same level?
My aim is to allow multiple groups (at least 8) that are a subset of the STANDARD1 tag, but are all at the same level.
Any ideas?
Thanks in advance,
LeanneI am facing same problem when i generate the xml from oracle reports. did you get any solution from this problem.
Thanks in advance, -
How to convert org hierarchy XML to CSV/Excel format using PI/XI
Hi All,
I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
Here is the example of how my input XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<PartyMaster type="OrgHierarchy" name="Compass Group Owned">
<PartyMasterHierarchy>
<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >
<Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
</Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".
<Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">
<Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">
<Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
</PartyMasterHierarchy>
</PartyMaster>
I would like to get CSV output in the format below
DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE
Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value
Levy Sector, Levy Sector, constant value, K00000, constant value
BA Division, BA Division, A00000, AB0000, constant value
Levy Sector Division, Levy Sector Division, K00000, K90000, constant value
BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value
Levy Sector Region, Levy Sector Region, K90000, K99000, constant value
Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value
TBA Total ,TBA Total ,K99000, K9901, constant value
1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Any help will be greatly appreciated.
Thanks.
--Mithun>>> 1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
Use File adapter at the sender side to pick up the xml and use file adapter at the receiver side (message protocol file content conversion) to convert xml format to csv.
Basically you have to configure in the file adapter (FCC) on the receiver side to get desired csv structure from XML.
>>> 2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Configure sender file adapter to pick up the file from the specified directory. Configure receiver file (fcc adapter) to drop the csv file after conversion.
For sender adapter
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
For receiver adapter in our case FCC (FILE content Conversion) follow the link
http://help.sap.com/saphelp_NW04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
Hope answered your question.
Mapping area: simple suggestion. Keep input and output message same structure and do one to one mapping. In the receiver fcc adapter configure for csv structure following instruction given in the above second link
Note: FCC adapter does not support nested structure more than 2. So in your case you can achieve using conversion agent tool. Otherwise you might have to achieve through some graphical mapping. -
Insert XML file into Relational database model - no XMLTYPE!
Dear all,
How can I store a known complex XML file into an existing relational database WITHOUT using xmltypes in the database ?
I read the article on DBMS_XMLSTORE. DBMS_XMLSTORE indeed partially bridges the gap between XML and RDBMS to a certain extent, namely for simply structured XML (canonical structure) and simple tables.
However, when the XML structure will become arbitrary and rapidly evolving, surely there must be a way to map XML to a relational model more flexibly.
We work in a java/Oracle10 environment that receives very large XML documents from an independent data management source. These files comply with an XML schema. That is all we know. Still, all these data must be inserted/updated daily in an existing relational model. Quite an assignment isn't it ?
The database does and will not contain XMLTYPES, only plain RDBMS tables.
Are you aware of a framework/product or tool to do what DBMS_XMLSTORE does but with any format of XML file ? If not, I am doomed.
Cheers.
Luc.
Edited by: user6693852 on Jan 13, 2009 7:02 AMIn case you decide to follow my advice, here's a simple example showing how to do this.. (Note the XMLTable syntax is the preferred approach in 10gr2 and later..
SQL> spool testase.log
SQL> --
SQL> connect / as sysdba
Connected.
SQL> --
SQL> set define on
SQL> set timing on
SQL> --
SQL> define USERNAME = XDBTEST
SQL> --
SQL> def PASSWORD = XDBTEST
SQL> --
SQL> def USER_TABLESPACE = USERS
SQL> --
SQL> def TEMP_TABLESPACE = TEMP
SQL> --
SQL> drop user &USERNAME cascade
2 /
old 1: drop user &USERNAME cascade
new 1: drop user XDBTEST cascade
User dropped.
Elapsed: 00:00:00.59
SQL> grant create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &PASS
ORD
2 /
old 1: grant create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &
ASSWORD
new 1: grant create any directory, drop any directory, connect, resource, alter session, create view to XDBTEST identified by XDB
EST
Grant succeeded.
Elapsed: 00:00:00.01
SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
2 /
old 1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
new 1: alter user XDBTEST default tablespace USERS temporary tablespace TEMP
User altered.
Elapsed: 00:00:00.00
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> var SCHEMAURL varchar2(256)
SQL> var XMLSCHEMA CLOB
SQL> --
SQL> set define off
SQL> --
SQL> begin
2 :SCHEMAURL := 'http://xmlns.example.com/askTom/TransactionList.xsd';
3 :XMLSCHEMA :=
4 '<?xml version="1.0" encoding="UTF-8"?>
5 <!--W3C Schema generated by XMLSpy v2008 rel. 2 sp2 (http://www.altova.com)-->
6 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
7 <xs:element name="TransactionList" type="transactionListType" xdb:defaultTable="LOCAL_TABLE"/>
8 <xs:complexType name="transactionListType" xdb:maintainDOM="false" xdb:SQLType="TRANSACTION_LIST_T">
9 <xs:sequence>
10 <xs:element name="Transaction" type="transactionType" maxOccurs="unbounded" xdb:SQLCollType="TRANSACTION_V"
>
11 </xs:sequence>
12 </xs:complexType>
13 <xs:complexType name="transactionType" xdb:maintainDOM="false" xdb:SQLType="TRANSACTION_T">
14 <xs:sequence>
15 <xs:element name="TradeVersion" type="xs:integer"/>
16 <xs:element name="TransactionId" type="xs:integer"/>
17 <xs:element name="Leg" type="legType" maxOccurs="unbounded" xdb:SQLCollType="LEG_V"/>
18 </xs:sequence>
19 <xs:attribute name="id" type="xs:integer" use="required"/>
20 </xs:complexType>
21 <xs:complexType name="paymentType" xdb:maintainDOM="false" xdb:SQLType="PAYMENT_T">
22 <xs:sequence>
23 <xs:element name="StartDate" type="xs:date"/>
24 <xs:element name="Value" type="xs:integer"/>
25 </xs:sequence>
26 <xs:attribute name="id" type="xs:integer" use="required"/>
27 </xs:complexType>
28 <xs:complexType name="legType" xdb:maintainDOM="false" xdb:SQLType="LEG_T">
29 <xs:sequence>
30 <xs:element name="LegNumber" type="xs:integer"/>
31 <xs:element name="Basis" type="xs:integer"/>
32 <xs:element name="FixedRate" type="xs:integer"/>
33 <xs:element name="Payment" type="paymentType" maxOccurs="unbounded" xdb:SQLCollType="PAYMENT_V"/>
34 </xs:sequence>
35 <xs:attribute name="id" type="xs:integer" use="required"/>
36 </xs:complexType>
37 </xs:schema>';
38 end;
39 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> set define on
SQL> --
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(:XMLSCHEMA);
4 begin
5 dbms_xmlschema.registerSchema
6 (
7 schemaurl => :schemaURL,
8 schemadoc => xmlSchema,
9 local => TRUE,
10 genTypes => TRUE,
11 genBean => FALSE,
12 genTables => TRUE,
13 ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
14 );
15 end;
16 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.26
SQL> desc LOCAL_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.com/askTom/TransactionList.xsd" Element "TransactionList") STORAGE Object-rela
ional TYPE "TRANSACTION_LIST_T"
SQL> --
SQL> create or replace VIEW TRAN_VIEW
2 as
3 select
4 extractvalue(x.column_value,'/Transaction/TradeVersion/text()') tradeversion,
5 extractvalue(x.column_value,'/Transaction//text()') transactionid
6 from
7 local_table,
8 table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x
9 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_VIEW
2 as
3 select
4 extractvalue(x.column_value,'/Transaction/TransactionId/text()') transactionid,
5 extractvalue(y.column_value,'/Leg/Basis/text()') leg_basis,
6 extractValue(y.column_value,'/Leg/FixedRate/text()') leg_fixedrate
7 from
8 local_table,
9 table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x,
10 table(xmlsequence(extract(x.column_value,'/Transaction/Leg'))) y
11 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_PAY_VIEW
2 as
3 select
4 extractvalue(x.column_value,'/Transaction/TransactionId/text()') transactionid,
5 extractvalue(y.column_value,'/Leg/LegNumber/text()') leg_legnumber,
6 extractvalue(z.column_value,'/Payment/StartDate/text()') pay_startdate,
7 extractValue(z.column_value,'/Payment/Value/text()') pay_value
8 from
9 local_table,
10 table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x,
11 table(xmlsequence(extract(x.column_value,'/Transaction/Leg'))) y,
12 table(xmlsequence(extract(y.column_value,'/Leg/Payment'))) z
13 /
View created.
Elapsed: 00:00:00.03
SQL> desc TRAN_VIEW
Name Null? Type
TRADEVERSION NUMBER(38)
TRANSACTIONID VARCHAR2(4000)
SQL> --
SQL> desc TRAN_LEG_VIEW
Name Null? Type
TRANSACTIONID NUMBER(38)
LEG_BASIS NUMBER(38)
LEG_FIXEDRATE NUMBER(38)
SQL> --
SQL> desc TRAN_LEG_PAY_VIEW
Name Null? Type
TRANSACTIONID NUMBER(38)
LEG_LEGNUMBER NUMBER(38)
PAY_STARTDATE DATE
PAY_VALUE NUMBER(38)
SQL> --
SQL> create or replace VIEW TRAN_VIEW_XMLTABLE
2 as
3 select t.*
4 from LOCAL_TABLE,
5 XMLTable
6 (
7 '/TransactionList/Transaction'
8 passing OBJECT_VALUE
9 columns
10 TRADE_VERSION NUMBER(4) path 'TradeVersion/text()',
11 TRANSACTION_ID NUMBER(4) path 'TransactionId/text()'
12 ) t
13 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_VIEW_XMLTABLE
2 as
3 select t.TRANSACTION_ID, L.*
4 from LOCAL_TABLE,
5 XMLTable
6 (
7 '/TransactionList/Transaction'
8 passing OBJECT_VALUE
9 columns
10 TRANSACTION_ID NUMBER(4) path 'TransactionId/text()',
11 LEG XMLType path 'Leg'
12 ) t,
13 XMLTABLE
14 (
15 '/Leg'
16 passing LEG
17 columns
18 LEG_NUMBER NUMBER(4) path 'LegNumber/text()',
19 LEG_BASIS NUMBER(4) path 'Basis/text()',
20 LEG_FIXED_RATE NUMBER(4) path 'FixedRate/text()'
21 ) l
22 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_PAY_VIEW_XMLTABLE
2 as
3 select TRANSACTION_ID, L.LEG_NUMBER, P.*
4 from LOCAL_TABLE,
5 XMLTable
6 (
7 '/TransactionList/Transaction'
8 passing OBJECT_VALUE
9 columns
10 TRANSACTION_ID NUMBER(4) path 'TransactionId/text()',
11 LEG XMLType path 'Leg'
12 ) t,
13 XMLTABLE
14 (
15 '/Leg'
16 passing LEG
17 columns
18 LEG_NUMBER NUMBER(4) path 'LegNumber/text()',
19 PAYMENT XMLType path 'Payment'
20 ) L,
21 XMLTABLE
22 (
23 '/Payment'
24 passing PAYMENT
25 columns
26 PAY_START_DATE DATE path 'StartDate/text()',
27 PAY_VALUE NUMBER(4) path 'Value/text()'
28 ) p
29 /
View created.
Elapsed: 00:00:00.03
SQL> desc TRAN_VIEW_XMLTABLE
Name Null? Type
TRADE_VERSION NUMBER(4)
TRANSACTION_ID NUMBER(4)
SQL> --
SQL> desc TRAN_LEG_VIEW_XMLTABLE
Name Null? Type
TRANSACTION_ID NUMBER(4)
LEG_NUMBER NUMBER(4)
LEG_BASIS NUMBER(4)
LEG_FIXED_RATE NUMBER(4)
SQL> --
SQL> desc TRAN_LEG_PAY_VIEW_XMLTABLE
Name Null? Type
TRANSACTION_ID NUMBER(4)
LEG_NUMBER NUMBER(4)
PAY_START_DATE DATE
PAY_VALUE NUMBER(4)
SQL> --
SQL> set long 10000 pages 100 lines 128
SQL> set timing on
SQL> set autotrace on explain
SQL> set heading on feedback on
SQL> --
SQL> VAR DOC1 CLOB
SQL> VAR DOC2 CLOB
SQL> --
SQL> begin
2 :DOC1 :=
3 '<TransactionList>
4 <Transaction id="1">
5 <TradeVersion>1</TradeVersion>
6 <TransactionId>1</TransactionId>
7 <Leg id="1">
8 <LegNumber>1</LegNumber>
9 <Basis>1</Basis>
10 <FixedRate>1</FixedRate>
11 <Payment id="1">
12 <StartDate>2000-01-01</StartDate>
13 <Value>1</Value>
14 </Payment>
15 <Payment id="2">
16 <StartDate>2000-01-02</StartDate>
17 <Value>2</Value>
18 </Payment>
19 </Leg>
20 <Leg id="2">
21 <LegNumber>2</LegNumber>
22 <Basis>2</Basis>
23 <FixedRate>2</FixedRate>
24 <Payment id="1">
25 <StartDate>2000-02-01</StartDate>
26 <Value>10</Value>
27 </Payment>
28 <Payment id="2">
29 <StartDate>2000-02-02</StartDate>
30 <Value>20</Value>
31 </Payment>
32 </Leg>
33 </Transaction>
34 <Transaction id="2">
35 <TradeVersion>2</TradeVersion>
36 <TransactionId>2</TransactionId>
37 <Leg id="1">
38 <LegNumber>21</LegNumber>
39 <Basis>21</Basis>
40 <FixedRate>21</FixedRate>
41 <Payment id="1">
42 <StartDate>2002-01-01</StartDate>
43 <Value>21</Value>
44 </Payment>
45 <Payment id="2">
46 <StartDate>2002-01-02</StartDate>
47 <Value>22</Value>
48 </Payment>
49 </Leg>
50 <Leg id="22">
51 <LegNumber>22</LegNumber>
52 <Basis>22</Basis>
53 <FixedRate>22</FixedRate>
54 <Payment id="21">
55 <StartDate>2002-02-01</StartDate>
56 <Value>210</Value>
57 </Payment>
58 <Payment id="22">
59 <StartDate>2002-02-02</StartDate>
60 <Value>220</Value>
61 </Payment>
62 </Leg>
63 </Transaction>
64 </TransactionList>';
65 :DOC2 :=
66 '<TransactionList>
67 <Transaction id="31">
68 <TradeVersion>31</TradeVersion>
69 <TransactionId>31</TransactionId>
70 <Leg id="31">
71 <LegNumber>31</LegNumber>
72 <Basis>31</Basis>
73 <FixedRate>31</FixedRate>
74 <Payment id="31">
75 <StartDate>3000-01-01</StartDate>
76 <Value>31</Value>
77 </Payment>
78 </Leg>
79 </Transaction>
80 </TransactionList>';
81 end;
82 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SQL> insert into LOCAL_TABLE values ( xmltype(:DOC1))
2 /
1 row created.
Elapsed: 00:00:00.01
Execution Plan
Plan hash value: 1
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
| 1 | LOAD TABLE CONVENTIONAL | LOCAL_TABLE | | | | |
SQL> insert into LOCAL_TABLE values ( xmltype(:DOC2))
2 /
1 row created.
Elapsed: 00:00:00.01
Execution Plan
Plan hash value: 1
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
| 1 | LOAD TABLE CONVENTIONAL | LOCAL_TABLE | | | | |
SQL> select * from TRAN_VIEW_XMLTABLE
2 /
TRADE_VERSION TRANSACTION_ID
1 1
2 2
31 31
3 rows selected.
Elapsed: 00:00:00.03
Execution Plan
Plan hash value: 650975545
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3 | 168 | 3 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 3 | 168 | 3 (0)| 00:00:01 |
|* 2 | TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== | 3 | 138 | 3 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN| SYS_C0010174 | 1 | 10 | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("SYS_NC_TYPEID$" IS NOT NULL)
3 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
Note
- dynamic sampling used for this statement
SQL> select * from TRAN_LEG_VIEW_XMLTABLE
2 /
TRANSACTION_ID LEG_NUMBER LEG_BASIS LEG_FIXED_RATE
1 1 1 1
1 2 2 2
2 21 21 21
2 22 22 22
31 31 31 31
5 rows selected.
Elapsed: 00:00:00.04
Execution Plan
Plan hash value: 1273661583
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 560 | 7 (15)| 00:00:01 |
|* 1 | HASH JOIN | | 5 | 560 | 7 (15)| 00:00:01 |
| 2 | NESTED LOOPS | | 3 | 159 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== | 3 | 129 | 3 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN| SYS_C0010174 | 1 | 10 | 0 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | SYS_NTUmyermF/S721C/2UXo40Uw== | 5 | 295 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("SYS_ALIAS_1"."NESTED_TABLE_ID"="SYS_ALIAS_0"."SYS_NC0000800009$")
3 - filter("SYS_NC_TYPEID$" IS NOT NULL)
4 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statement
SQL> select * from TRAN_LEG_PAY_VIEW_XMLTABLE
2 /
TRANSACTION_ID LEG_NUMBER PAY_START PAY_VALUE
1 1 01-JAN-00 1
1 1 02-JAN-00 2
1 2 01-FEB-00 10
1 2 02-FEB-00 20
2 21 01-JAN-02 21
2 21 02-JAN-02 22
2 22 01-FEB-02 210
2 22 02-FEB-02 220
31 31 01-JAN-00 31
9 rows selected.
Elapsed: 00:00:00.07
Execution Plan
Plan hash value: 4004907785
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 9 | 1242 | 10 (10)| 00:00:01 |
|* 1 | HASH JOIN | | 9 | 1242 | 10 (10)| 00:00:01 |
|* 2 | HASH JOIN | | 5 | 480 | 7 (15)| 00:00:01 |
| 3 | NESTED LOOPS | | 3 | 159 | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== | 3 | 129 | 3 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN| SYS_C0010174 | 1 | 10 | 0 (0)| 00:00:01 |
|* 6 | TABLE ACCESS FULL | SYS_NTUmyermF/S721C/2UXo40Uw== | 5 | 215 | 3 (0)| 00:00:01 |
|* 7 | TABLE ACCESS FULL | SYS_NTelW4ZRtKS+WKqCaXhsHnNQ== | 9 | 378 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("NESTED_TABLE_ID"="SYS_ALIAS_1"."SYS_NC0000900010$")
2 - access("SYS_ALIAS_1"."NESTED_TABLE_ID"="SYS_ALIAS_0"."SYS_NC0000800009$")
4 - filter("SYS_NC_TYPEID$" IS NOT NULL)
5 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
6 - filter("SYS_NC_TYPEID$" IS NOT NULL)
7 - filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statement
SQL>Out of interest why are you so against using XMLType...
Edited by: mdrake on Jan 13, 2009 8:25 AM -
Database data to nested xml structure
Hi All,
I need to convert the data in the oracle database to nested xml tree structure as below:
Data in the database is in the following structure:
1 branch1 13-JAN-11 a.txt
1 branch1 25-JAN-11 b.txt
1 branch1 25-JAN-11 c.txt
1 branch2 20-JAN-11 d.txt
2
XML for the above data should be in the format:
<Root>
<Account_no value="1">
<Desc value="branch1">
<Date value="13-JAN-11">
<Name value="a.txt"/>
</Date>
<Date value="25-JAN-11">
<Name value="b.txt"/>
<Name value="c.txt"/>
</Date>
</Desc>
<Desc value="branch2">
<Date value="20-JAN-11">
<Name value="d.txt"/>
</Date>
</Desc>
</Account_no>
<Account_no value="2">
</Account_no>
</Root>
I am able to get this kind of xml structure using java after storing the database data in a n-ary tree. But it takes more time to execute.
Can this kind of same xml format be achieved using pl/sql programming?
Please help me with your valuable insights.
Thanks,
AlagappanHi,
Please always mention your db version (select * from v$version).
Here's one solution using SQL/XML functions :
Sample data used :
create table sample_data
account_no number,
description varchar2(30),
dt date,
name varchar2(30)
insert into sample_data values(1, 'branch1', to_date('13-JAN-11','DD-MON-RR'), 'a.txt');
insert into sample_data values(1, 'branch1', to_date('25-JAN-11','DD-MON-RR'), 'b.txt');
insert into sample_data values(1, 'branch1', to_date('25-JAN-11','DD-MON-RR'), 'c.txt');
insert into sample_data values(1, 'branch2', to_date('20-JAN-11','DD-MON-RR'), 'd.txt');
insert into sample_data values(2, 'branch3', to_date('20-JAN-11','DD-MON-RR'), 'e.txt');Query :
SELECT xmlserialize(document
xmlelement("Root",
xmlagg(
xmlelement("Account_no", xmlattributes(account_no as "value"),
xmlagg(
xmlelement("Desc", xmlattributes(description as "value"), dt)
order by description
) order by account_no
as clob indent ) doc
FROM (
SELECT account_no, description,
xmlagg(
xmlelement("Date", xmlattributes(to_char(dt,'DD-MON-RR') as "value"), name)
order by dt
) dt
FROM (
SELECT account_no, description, dt,
xmlagg(
xmlelement("Name", xmlattributes(name as "value"))
order by name
) name
FROM sample_data
GROUP BY account_no, description, dt
GROUP BY account_no, description
GROUP BY account_no
DOC
<Root>
<Account_no value="1">
<Desc value="branch1">
<Date value="13-JAN-11">
<Name value="a.txt"/>
</Date>
<Date value="25-JAN-11">
<Name value="b.txt"/>
<Name value="c.txt"/>
</Date>
</Desc>
<Desc value="branch2">
<Date value="20-JAN-11">
<Name value="d.txt"/>
</Date>
</Desc>
</Account_no>
<Account_no value="2">
<Desc value="branch3">
<Date value="20-JAN-11">
<Name value="e.txt"/>
</Date>
</Desc>
</Account_no>
</Root>
Here, I used XMLSerialize function with indent option to format the output (available starting with 11g). -
How to convert hierarchy XML to CSV/Excel format using PI/XI
posted in PI forum but not many replies, please bear with me as I am in crunch time*
Hi All,
I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
Here is the example of how my input XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<PartyMaster type="OrgHierarchy" name="Compass Group Owned">
<PartyMasterHierarchy>
<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >
<Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
</Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".
<Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">
<Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">
<Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
</PartyMasterHierarchy>
</PartyMaster>
I would like to get CSV output in the format below
DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE
Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value
Levy Sector, Levy Sector, constant value, K00000, constant value
BA Division, BA Division, A00000, AB0000, constant value
Levy Sector Division, Levy Sector Division, K00000, K90000, constant value
BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value
Levy Sector Region, Levy Sector Region, K90000, K99000, constant value
Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value
TBA Total ,TBA Total ,K99000, K9901, constant value
1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Any help will be greatly appreciated.
Thanks.
--MithunHi Mithun,
You might try this step below :
1. As for xsd schema fo the xml or create xsd schema base on the sample xml file using tools like xmlspy or others free tools.
2. import you xsd schema as outbound Data type
3. apply mapping from source to target (csv).
Configuration
Sender file adapter (without content conversion)
Receiver file adapter (with content conversion).
so the sender adapter will be monitoring inbound directory and write the result to another directory.
Thank You and Best Regards
Fernand.
Maybe you are looking for
-
MSI CX61 2PC multimedia notebook, the choice of students and office users
Slim and slight, MSI's CX61 presents good performance of the latest laptops for casual and online gaming competitions. Under the hood, these NBs meet your need for machines that with good performance with better user experience. In addition, unique A
-
How to get settings to work again?
I just finished unblocking my iPhone for the third time and now settings does not want to work! Please help.
-
Cannot access the content producer portal via reverse proxy
Hi all, I hope my post is in the right forum We have an FPN environment using RRA with our EP (NW 7.0 SPS18) as the consumer and our BI portal (NW 7.0 SPS18) as the content producer. The consumer is registered with the producer using HTTP protocol.
-
I have a new Powerbook running snow leopard. Several times when it wakes from sleep, I get a warning "Another computer on the network has the name 'LapMac' Your computer's name is now LapMac(2)" Of course, there is no other computer with this name on
-
2100 WLC 1130 APs - need some help please
It's been about 5 years since I took my CCNA course and could use some help on a wireless set up for church. We have a Catalyst 3550 that is running fine, just a few VLANs, including 30 for public wireless. I've then got a 2100 WLC and (3) 1130 AP's