Thursday, May 21, 2009

Simple Query to generate XML output

1. SELECT SYS_XMLAGG (SYS_XMLGEN (order_number), SYS.xmlgenformattype.createformat ('OE_ORDER_HEADERS_ALL')).getstringval () AS xml_row
FROM oe_order_headers_all
WHERE ROWNUM < 6

2. SELECT SYS_XMLAgg(
SYS_XMLGen(
TABLE(OE_ORDER_HEADERS_ALL, APPS_TS_TX_DATA),
sys.xmlgenformatType.createFormat('TABLE')
),
sys.xmlgenformatType.createFormat('USER_TABLES')
).getStringVal() AS xml_row
FROM user_tables
WHERE rownum < 6;

3. select sys_XMLAgg(xmlforest(header_id, order_number),sys.xmlgenformatType.createFormat('order')).getStringVal() AS xml_row from oe_order_headers_all
WHERE rownum < 6

4. SELECT XMLAgg(
XMLELEMENT
(header_id , order_number
)
).getStringVal() AS xml_row
FROM oe_order_headers_all
WHERE rownum < 6

No comments:

Post a Comment