How to generate the following XML
Hi allI have 2 tables, demo_orders and demo_order_items (child)
How can I generate something like this:
<?xml version="1.0"?>
<ROWSET>
<ROW>
<ORDER_ID>1</ORDER_ID>
<CUSTOMER_ID>1</CUSTOMER_ID>
<ORDER_TOTAL>1200</ORDER_TOTAL>
<ORDER_TIMESTAMP>2009-01-16T16:20:09.000</ORDER_TIMESTAMP>
<USER_ID>2</USER_ID>
<ITEMS>
<ITEMROW>
<ORDER_ITEM_ID>1</ORDER_ITEM_ID>
<ORDER_ID>1</ORDER_ID>
<PRODUCT_ID>1</PRODUCT_ID>
<UNIT_PRICE>1200</UNIT_PRICE>
<QUANTITY>1</QUANTITY>
</ITEMROW>
</ITEMS>
</ROW>
<ROW>
<ORDER_ID>2</ORDER_ID>
<CUSTOMER_ID>2</CUSTOMER_ID>
<ORDER_TOTAL>599</ORDER_TOTAL>
<ORDER_TIMESTAMP>2009-01-11T16:20:09.000</ORDER_TIMESTAMP>
<USER_ID>2</USER_ID>
<ITEMS>
<ITEMROW>
<ORDER_ITEM_ID>2</ORDER_ITEM_ID>
<ORDER_ID>2</ORDER_ID>
<PRODUCT_ID>2</PRODUCT_ID>
<UNIT_PRICE>199</UNIT_PRICE>
<QUANTITY>1</QUANTITY>
</ITEMROW>
<ITEMROW>
<ORDER_ITEM_ID>3</ORDER_ITEM_ID>
<ORDER_ID>2</ORDER_ID>
<PRODUCT_ID>8</PRODUCT_ID>
<UNIT_PRICE>50</UNIT_PRICE>
<QUANTITY>2</QUANTITY>
</ITEMROW>
</ITEMS>
</ROW>
</ROWSET>
Hi, I am assuming that the columns of the table have the same names as the xml elements in your example.
Try this:
SQL >select xmlelement("ROWSET",
2 xmlagg(xmlelement("ROW",xmlforest(order_id,
3 customer_id,
4 order_total,
5 to_char(order_timestamp,'yyyy-mm-dd"T"hh24:mi:ss.FF3') as "ORDER_TIMESTAMP",
6 user_id),
7 xmlelement("ITEMS",(select
8 xmlagg(xmlelement("ITEMROW",xmlforest(order_item_id,
9 order_id,
10 product_id,
11 unit_price,
12 quantity)
13 )
14 ) from demo_order_items i where i.order_id=o.order_id)
15 )
16 )
17 )
18 ).extract('/*') as yourXML
19 from demo_orders o;
YOURXML
--------------------------------------------------------------------------------------------------------------
1
1
1200
2009-12-28T10:19:01.464
2
1
1
1
1200
1
2
2
599
2009-12-28T10:19:01.464
2
2
2
2
199
1
3
2
8
50
2
The extract('/*') method is useful enough formatted output. Remove in your production applications to improve performance and space-saving.
Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2009/12/27/inviare-email-dal-db-utilizzando-utl_smtp/]
Tags: Database
Similar Questions
-
How to generate the tag xml from oracle pl/sql
Hi all
I have my db is version 10.2.0.3.0 - Production
I tried a few examples
The first is xmlgen.getXml like that
SELECT dbms.xmlgen.getXml)
' SELECT order_number "EMP_NO".
, header_id 'NAME '.
, org_id "DEPT_NO.
Of oe_order_headers_all
WHERE header_id = 39441'
) OF THE double;
but I think xmlgen.getXm is not a valid identifier
Secondly, I tried like this
SELECT e.employee_id,
XMLELEMENT ("Emp", e.first_name |) » '|| Select) AS 'RESULT '.
OF e hr.employees
but the expected production is like that
1001 < Emp > John 6000 < / Emp >
but I'm getting
10 (ORAXML)
Someone could tell me what error or no matter what format was changed
Thanks and greetings
Srikkanthexample:
SQL> ed Wrote file afiedt.buf 1 SELECT dbms_xmlgen.getXml( 2 'SELECT empno "EMP_NO" 3 , ename "NAME" 4 , deptno "DEPT_NO" 5 FROM emp' 6* ) FROM dual SQL> / DBMS_XMLGEN.GETXML('SELECTEMPNO"EMP_NO",ENAME"NAME",DEPTNO"DEPT_NO"FROMEMP') --------------------------------------------------------------------------------
7369 SMITH 20 7499 ALLEN 30 7521 WARD 30 7566 JONES 20 7654 MARTIN 30 7698 BLAKE 30 7782 CLARK 10 7788 SCOTT 20 7839 KING 10 7844 TURNER 30 7876 ADAMS 20 7900 JAMES 30 7902 FORD 20 7934 MILLER 10 -
How to generate the array Diagnostic Utility ADU for Esxi server
How to run Diagnostic Utility ADU or HP Insight Diagnostics HP Insight Diagnostics table to collect the status tables and logs data FRO an Esxi Server
How to generate the array Diagnostic Utility ADU for Esxi server
Example:
Download the package .vib here: http://vibsdepot.hp.com/hpq/feb2013/esxi-5x-vibs/hpacucli/hpacucli-9.40-12.0.vib
and place it on a store of data seen by the host...
Install it using the CLI:
software esxcli vib install d vmfs/volumes /
/hpacucli-9.40-12.0.vib Now run it:
~ # cd/opt/hp/hpacucli/bin
/ opt/HP/hpacucli/bin # . / hpacucli
HP Array Configuration Utility CLI 9.40.12.0
Detection of controllers... Fact.
Type 'help' for a list of supported commands.
Type "exit" to close the console.
=> ctrl all diag file=/tmp/my_ADUreport.zip ris = on = on zip xml = on
Generation of diagnostic report... done
-Online output
/ opt/HP/hpacucli/bin #.
my_ADUreport.zip in / tmp can now be downloaded from the host...
It could be that useful...
/ Rubeck
-
How to generate the password encoded using agent in ODI?
Hello
I've created a scenario and I plan to them. Now, I want to create an autonomous agent to run this scenario. To do this, I update odiparams.bat file where I am mentioning the details of the repository. I want to generate the encoded password repository connection using batch processing utility officer. After you type following command at the command prompt in windows xp:
agent to encode the password
Failure of the sound connection password invalid username error display.
What should do? How to generate the password encoded using batch agent utility?
Thank you
Shrinivas
Published by: Shrinivas Dayma on 13 Aug 2011 02:03Hi Shrinivas,
This command is for ODI 10 g.
For 11g,.
Encode
Thank you
Guru -
How to generate the report on rules
How to generate the report on rules with id recipient and with a few keyoword in a rule.
The rule management dashboard has an integrated 'report rules', you can configure properties and input parameters.
For rule management dashboard, click homes > Administration > rules. In the upper right, next to the date and time, click reports.
You can also find these helpful videos: http://edocs.quest.com/foglight/5610/Foglight_Reports_videos.php
Hope this helps,
Shay
-
How to generate the alert when pageitem move on the page? and what class boss be use to move pageitem
Hi Philippe,.
You can see the kDocBoss for the ClassID with the PMIID IID_ITRANSFORM_DOCUMENT kLocationChangedMessage.
Markus
-
How to generate the sequence Island-1, -1, 1, 1...
How to generate the sequence Island-1, -1, 1, 1...This seems to work:
create sequence sss start with -1 increment by 2 minvalue -1 maxvalue 1 cycle nocache;
-
How to generate the ddl for unlimited quota
Hi all
DB: Oracle 9.2.0.4
OS: Solaris 8
I have a 12 tablespaces and 18 users of the application.
I would like to grant an unlimited quota for all users on all areas of storage, to find out how to generate the ddl script.
ex: change the dataagent user quota unlimited on DSOM.
can anyone help us.
Thank you
KK.All users in all areas of storage?
Select "edit user" | user name | "quota unlimited on | nom_tablespace | ';'
from dba_users cross join dba_tablespaces
When not in dba_tablespaces.tablespace_name ('SYSTEM', "SYSAUX");Please, be careful with this
HTH
Antonio NAVARRO -
How to generate the script to insert data tables present in a
How to generate the script to insert data from one table in an entire schema under environment sqlplus
with toads it please help me please!905310 wrote:
How to generate the script to insert data from one table in an entire schema under environment sqlplus
with toads it please help me please!The correct method by using the pump of the database or import/export or unload the data in CSV format for loading using SQL * Loader.
Generate instructions insert with literals is very bad choices - the bind variable is missing. It will be quite slow because many other CPU cycles are spend on hard analysis. The shared pool will become fragmented. This can cause errors of memory for other applications when they attempt to analyze SQLs for cursors.
-
How to generate the random password policy password knowing resources
Hello
Any body tell me how to generate the random password policy password knowing the purpose of resource in OIM11g
Kind regards
Mireille NayanHi Pascal,.
You can try the below code snippet:
UserRepository your = new DBUserRepository();
UserInfo user = your.getUserInfo (take);
ResourceRepository rrepo = new ResourceDBRepository();
Resource = rrepo.findResource (resourceName);
By PasswordPolicyAssignmentsRepository = new PasswordPolicyAssignmentsDBRepository();
PasswordPolicyRepository ppr = new DBPasswordPolicyRepository();
The list of passwordPolicyAssignments = par.getPasswordPolicyAssigments (resource);
PasswordPolicy passwordPolicy;
PasswordPolicyAssignment passwordPolicyAssignment = passwordPolicyAssignments.get (0) (PasswordPolicyAssignment);
If (isApplicable (passwordPolicyAssignment, {getMappedAttributes (userInfo.getAttributes ())})})
passwordPolicy = ppr.find (passwordPolicyAssignment.getPasswordPolicyID ());
}
RPG RandomPasswordGeneratorImpl = new RandomPasswordGeneratorImpl();
password = rpg.generatePassword (userInfo, passwordPolicy);Kind regards
GYAN -
How to generate the WSDL in CCB231
How to generate the WSDL in ccb231? I'm not able to use the WSDL generated to XAI inbound service like soapUI gives importing problem. I couldn't open the schema editor to generate the WSDL as ODBC driver is missing from my windows machine 7. Any suggestions pleaseWhat kind of import errors that you get with soapUI?
I have a virtual machine running CC & B 2.3.1 with SoapUI 3.6.1 and when I import the WSDL generated by XAI Inbound Service it runs smoothly.
-
How to convert the following code in as3?
As the title says... How to convert the following code to as3?... Thanks in advance.
import flash.display.BitmapData;
linkageId = "landscape";
myBitmapData = BitmapData.loadBitmap (linkageId);
MC = this.createEmptyMovieClip ("mc", 1);
mc.attachBitmap (myBitmapData, 1);onMouseMove = function() {}
myNewColor = "0 x" + myBitmapData.getPixel(_xmouse,_ymouse).toString (16);
newColor.setRGB (myNewColor);
selectedColor.colorValue.text = myNewColor;
}
selectedColor.swapDepths (_root.getNextHighestDepth ());
newColor = new Color (selectedColor.sample);:
var myBitmapData:landscape = new landscape (0,0);
var bmp:Bitmap = new Bitmap (myBitmapData);
addChild (bmp);stage.addEventListener (MouseEvent.MOUSE_MOVE, f);
function f(e:MouseEvent):void {}
var myNewColor:String = "0 x" + myBitmapData.getPixel(mouseX,mouseY).toString (16);
newColorTransform.color = uint (myNewColor);
selectedColor.sample.transform.colorTransform = newColorTransform;
selectedColor.colorValue.text = myNewColor;
}
addChild (selectedColor);
var newColorTransform:ColorTransform = selectedColor.sample.transform.colorTransform; -
How to explain the following code?
How to explain the following code?
1 set setOpenTradeIds = mapTrades.keySet (filter);
2 map mapResults = null agent, map.invokeAll ((Filter));
Is defined a class and setOPenTradeIds a new object?
Is card calss and mapResults a new object?
Thank you
Published by: frank.qian on June 7, 2009 10:48Hi Frank,.
Is mapTrades an object and a set of keys one of its methods?
mapTrade is a reference variable refers to an instance of a class that implements the keySet() method that returns a reference to an instance of a class that implements the interface of game
What is map.invokeAll? Where to get the information about it?
map is a reference variable refers to an instance of a class that implements the invokeAll() method that returns a reference to an instance of a class that implements the map interface In case of card to make reference to an instance of a class that implements the InvocableMap interface, you can find consistency documentation 3.4.2 method to InvocableMap.
Kind regards
Harv
-
How to generate the full javadoc?
How to generate the full javadoc?
I create several javabeans and each of them has one or more methods. I add javadoc comments and run javadoc * .java. It can create new javadoc, but only for this java class.
How to generate a full javadoc?
I use Jdeveloper 10 g. If someone knows how to do in Jdeveloper 10 and 11g, please help me.
Thank youYE,
11 g, you can right click on the project and choose "javadoc
. In 10g, you can select the project and choose the menu 'javadoc
' run. John
-
How to generate the xml tag empty when meets elements void inside
Hi gurus,
IAM facing a problem to generate the empty tag, here is my file that I'm generating now
current I'm generating tags EXCEPTION even if it is null as<HEADER> <MINISTRY_CODE>RPO</MINISTRY_CODE> <DEPARTMENT_CODE>000</DEPARTMENT_CODE> <ORDER_CODE>RPO000EPO11001002</ORDER_CODE> <EXTERNAL_SYSTEM_CODE>E</EXTERNAL_SYSTEM_CODE> <AMENDMENT_NUMBER>0</AMENDMENT_NUMBER> <VARIATION_NUMBER>0</VARIATION_NUMBER> <EXCEPTIONS> <EXCEPTION> <EXCEPTION_CODE>PO016</EXCEPTION_CODE> <EXCEPTION_LONG_DESC>PO cannot be created/amended successfully</EXCEPTION_LONG_DESC> </EXCEPTION> </EXCEPTIONS> </HEADER> <ITEMS> <ITEM> <LINE_NUMBER>1</LINE_NUMBER> <EXCEPTIONS> <EXCEPTION> <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> </EXCEPTION> </EXCEPTIONS> <LOCATIONS> <LOCATION> <LINE_NUMBER>1</LINE_NUMBER> <EXCEPTIONS> <EXCEPTION> <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> </EXCEPTION> </EXCEPTIONS> <DISTRIBUTIONS> <DISTRIBUTION> <LINE_NUMBER>1</LINE_NUMBER> <EXCEPTIONS> <EXCEPTION> <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> </EXCEPTION> </EXCEPTIONS> </DISTRIBUTION> </DISTRIBUTIONS> </LOCATION> </LOCATIONS> </ITEM> </ITEMS> </GEBIZ_ORDER_ACK>
< EXCEPTIONS >
< EXCEPTION >
< EXCEPTION_CODE xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: Nil = "true" / >
< EXCEPTION_LONG_DESC xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: Nil = "true" / >
< / EXCEPTION >
< / EXCEPTIONS >
but my requirement is them does not when the exception code is null and generate as
< EXCEPTIONS / >
This is sql that I use to generate the above said code let me know how can I control who
It's urgent please help in this regard.SELECT xmlserialize(document xmlelement("GEBIZ_ORDER_ACK" , xmlagg( xmlconcat(hdr, dtls) ) ) as clob indent size = 2 ) -- INTO lv_out FROM ( SELECT xmlelement("HEADER" , xmlelement("MINISTRY_CODE", poh.ministry_code) , xmlelement("EXCEPTIONS" , xmlelement("EXCEPTION" , xmlelement("EXCEPTION_CODE" --,NVL(poh.exception_code,'NULL') , xmlattributes( NVL2(poh.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(poh.exception_code,null,'true') as "xsi:nil" ) ,poh.exception_code) , xmlelement("EXCEPTION_LONG_DESC" , xmlattributes( NVL2(poh.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(poh.exception_long_desc,null,'true') as "xsi:nil" ) ,poh.exception_long_desc) ) ) ) hdr , xmlelement("ITEMS" , xmlagg( xmlelement("ITEM" ,xmlelement("LINE_NUMBER", v1.line_no) ,xmlelement("EXCEPTIONS" , xmlelement("EXCEPTION" , xmlelement("EXCEPTION_CODE" --,NVL(v1.exception_code,'NULL') , xmlattributes( NVL2(v1.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(v1.exception_code,null,'true') as "xsi:nil" ) , v1.exception_code) , xmlelement("EXCEPTION_LONG_DESC" , xmlattributes( NVL2(v1.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(v1.exception_long_desc,null,'true') as "xsi:nil" ) ,v1.exception_long_desc) ) ) ,xmlelement("LOCATIONS" ,( SELECT xmlagg( xmlelement("LOCATION" , xmlelement("LINE_NUMBER",v2.location_line_no) , xmlelement("EXCEPTIONS" , xmlelement("EXCEPTION" , xmlelement("EXCEPTION_CODE" --,NVL(v2.exception_code,'NULL') , xmlattributes( NVL2(v2.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(v2.exception_code,null,'true') as "xsi:nil" ) , v2.exception_code) , xmlelement("EXCEPTION_LONG_DESC" , xmlattributes( NVL2(v2.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(v2.exception_long_desc,null,'true') as "xsi:nil" ) ,v2.exception_long_desc) ) ) ,xmlelement("DISTRIBUTIONS" ,(SELECT xmlagg ( xmlelement("DISTRIBUTION" ,xmlelement("LINE_NUMBER", v3.distribution_line_no) ,xmlelement("EXCEPTIONS" , xmlelement("EXCEPTION" , xmlelement("EXCEPTION_CODE"--,NVL(v3.exception_code,'NULL') , xmlattributes( NVL2(v3.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(v3.exception_code,null,'true') as "xsi:nil" ) ,v3.exception_code) , xmlelement("EXCEPTION_LONG_DESC" , xmlattributes( NVL2(v3.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi" , NVL2(v3.exception_long_desc,null,'true') as "xsi:nil" ) ,v3.exception_long_desc) ) ) ) ORDER BY v3.distribution_line_no ) FROM xgbz_fin_stage_ack_pot_v@dev_1157.RP.EDU.SG v3 WHERE v2.po_cont_code = v3.po_cont_code AND v2.line_no = v3.line_no AND v2.location_line_no = v3.location_line_no AND v2.fs_timestamp = v3.fs_timestamp AND v3.tx_timestamp IS NULL ) ) ) ORDER BY v2.location_line_no ) FROM xgbz_fin_stage_ack_pol_v@dev_1157.RP.EDU.SG v2 WHERE v2.line_no = v1.line_no AND v2.po_cont_code = v1.po_cont_code AND v2.fs_timestamp = v1.fs_timestamp AND v2.TX_TIMESTAMP IS NULL ) ) ) ORDER BY v1.line_no ) ) dtls FROM xgbz_fin_stage_ack_poh_v@dev_1157.rp.edu.sg poh, xgbz_fin_stage_ack_pod_v@dev_1157.rp.edu.sg v1 WHERE v1.po_cont_code = poh.po_cont_code AND v1.fs_timestamp = poh.fs_timestamp AND v1.tx_timestamp IS NULL AND poh.tx_timestamp IS NULL AND poh.po_cont_code = rec_po_ack.po_cont_code GROUP BY poh.po_cont_code,poh.ext_system_code,poh.amendment_no,poh.variation_no,poh.exception_code,poh.exception_long_desc, poh.ministry_code, poh.dept_code)
Thanks in advance.
Concerning
Mr. NagendraHello
Here are two possible solutions:
xmlelement("EXCEPTIONS", xmlforest( xmlforest( v1.exception_code as "EXCEPTION_CODE" , v1.exception_long_desc as "EXCEPTION_LONG_DESC" ) as "EXCEPTION" ) )
Mun
xmlelement("EXCEPTIONS", case when v1.exception_code is not null or v1.exception_long_desc is not null then xmlelement("EXCEPTION", xmlforest( v1.exception_code as "EXCEPTION_CODE" , v1.exception_long_desc as "EXCEPTION_LONG_DESC" ) ) end )
Maybe you are looking for
-
Hello For three days my finder no longer works correctly. I see my 'applications' and "all my files", but the rest of "documents", "desktop" and "House" no longer show files. I tried to move the file 'com.apple.finder.plist '. But it does not help. M
-
my iPhone 5s did pay almost 3 days in a row and has not lit, what should I do?
-
Videos continue to download after the closure of the tabs
When I discover a video in firefox, and then close the tab to half way through the video that my network meter says that something is still being downloaded. In my avg Task Manager it says firefox still uses my connection. but also, if I close firefo
-
Try to update to Yosemite to El Capitan and it says that it cannot be installed on Macintosh HD
Can I update 10.10.5 to the new El Capitan Yosemite. I'm new to Mac... since 2 January 2016. Need some advice! Thank you Dyer
-
ACS 5.1 allowing accountants
Hello I'm working on version 5.1 of the ACS. My customer requriements are supposed to check everything that things has authenticated the user did an AAA clients. For that I have to activate the posting. But my problem is that I don't see any option i