Generating Nested XML Documents
Hi,
We want to generate nested XML documents from sql queries using pl/sql.
If the output of the query is
EMPNO NAME MGRNO
1 Super Admin 0
2 Mgr1 1
4 SubMgr1_1 2
5 SubMgr2_1 2
3 Mgr2 1
6 SubMgr1_2 3
then XML generated should be in the format
Super Admin
Mgr1
SubMgr1_1
SubMgr2_1
Mgr2
SubMgr1_2
Your early response is appreciated.
Thanks.
No, the id is not unique, it is part of the data. Also, I don't need to update the XML document.
I store the data part (id, status, nodenum) in the "resp" table with a primary key as a combination of id and some other info. The table "nodes" will have a foreign key and multiple occurrences of node. Same with table "restricts" with multiple restrict.
Do I need to create a DOM tree then store each part of the XML into appropriate tables? And how do I do that? (which APIs, etc.)
Thanks,
Thuvan
Similar Messages
-
Generating nested XML with XSU
Hi,
I have been trying to generate a nested XML document with the
XSU Utility (Rdbms 9.0.1) by setting up an nested table (see below)
and the using the command line utiliy as:
c:\>java OracleXML getXML -user "scott/tiger" "SELECT * from dept_type_tab
The result is nested all right, but all texts seem to be in Hex representation:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPT>
<DNAME>0x5245534541524348</DNAME>
<EMP>
<ENAME>0x534D495448</ENAME>
</EMP>
</DEPT>
</ROW>
Can anyone point out to me, where I went wrong? ;-(
Thanx for any input
Jan-Peter
create type emp_type as object
ename varchar2(10)
create type dept_type as object
dname varchar2(14),
emp emp_type
create view tmp_jpm2 as
select dept_type(dept.dname,
emp_type(emp.ename)
) dept
from dept, emp WHERE (dept.deptno = emp.deptno);
create table dept_type_tab ( dept dept_type);
insert into dept_type_tab (dept) select dept from tmp_jpm2;Hi,
I have been trying to generate a nested XML document with the
XSU Utility (Rdbms 9.0.1) by setting up an nested table (see below)
and the using the command line utiliy as:
c:\>java OracleXML getXML -user "scott/tiger" "SELECT * from dept_type_tab
The result is nested all right, but all texts seem to be in Hex representation:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPT>
<DNAME>0x5245534541524348</DNAME>
<EMP>
<ENAME>0x534D495448</ENAME>
</EMP>
</DEPT>
</ROW>
Can anyone point out to me, where I went wrong? ;-(
Thanx for any input
Jan-Peter
create type emp_type as object
ename varchar2(10)
create type dept_type as object
dname varchar2(14),
emp emp_type
create view tmp_jpm2 as
select dept_type(dept.dname,
emp_type(emp.ename)
) dept
from dept, emp WHERE (dept.deptno = emp.deptno);
create table dept_type_tab ( dept dept_type);
insert into dept_type_tab (dept) select dept from tmp_jpm2; -
Generating an XML Document from an internal table in ABAP
Good day to all of you;
With ABAP, in the R/3 system, I'm trying to figure out a way to accomplish the following:
1) SELECT a set of Purchase Order data into an internal table.
2) Generate an XML document, containing the above data, using a specific schema.
I've been playing around with function module SAP_CONVERT_TO_XML_FORMAT which has the following interface:
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ''
I_LINE_HEADER = ''
I_FILENAME = v_fname
I_APPL_KEEP = ''
I_XML_DOC_NAME = v_docname
IMPORTING
PE_BIN_FILESIZE = v_byte
TABLES
I_TAB_SAP_DATA = i_SapData
CHANGING
I_TAB_CONVERTED_DATA = i_XMLData
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
I'm uncertain as to whether or not the Export parameter, I_XML_DOC_NAME refers to some schema or definition and therefore have been excluding it. In doing so, the generated XML document seems to use the field name/type information from my itab for the tags.
If this function module requires an XML Document Name, how do I create one and where do I store it in R/3? If this is not the recommended solution, is anyone familiar with a way to load an XML schema, retrieve some data then have SAP generate an XML document using the schema?
Many thanks for any help available.
THai Phillips
Try with the following Code
This program exports an internal table to an XML file.
Report ZPRUEBA_MML_13 *
Export an internal table to XML document *
NO BORRAR ESTE CODIGO *
REPORT ZPRUEBA_MML_13.
PANTALLA SELECCION *
PARAMETERS: GK_RUTA TYPE RLGRAP-FILENAME.
PANTALLA SELECCION *
TYPE TURNOS *
TYPES: BEGIN OF TURNOS,
LU LIKE T552A-TPR01,
MA LIKE T552A-TPR01,
MI LIKE T552A-TPR01,
JU LIKE T552A-TPR01,
VI LIKE T552A-TPR01,
SA LIKE T552A-TPR01,
DO LIKE T552A-TPR01,
END OF TURNOS.
TYPE TURNOS *
TYPE SOCIO *
TYPES: BEGIN OF SOCIO,
NUMERO LIKE PERNR-PERNR,
REPOSICION LIKE PA0050-ZAUVE,
NOMBRE LIKE PA0002-VORNA,
TURNOS TYPE TURNOS,
END OF SOCIO.
TYPE SOCIO *
ESTRUCTURA ACCESOS *
DATA: BEGIN OF ACCESOS OCCURS 0,
SOCIO TYPE SOCIO,
END OF ACCESOS.
ESTRUCTURA ACCESOS *
START OF SELECTION *
START-OF-SELECTION.
PERFORM LLENA_ACCESOS.
PERFORM DESCARGA_XML.
END-OF-SELECTION.
END OF SELECTION *
FORM LLENA_ACCESOS *
FORM LLENA_ACCESOS.
REFRESH ACCESOS.
CLEAR ACCESOS.
MOVE: '45050' TO ACCESOS-SOCIO-NUMERO,
'MOISES MORENO' TO ACCESOS-SOCIO-NOMBRE,
'0' TO ACCESOS-SOCIO-REPOSICION,
'T1' TO ACCESOS-SOCIO-TURNOS-LU,
'T2' TO ACCESOS-SOCIO-TURNOS-MA,
'T3' TO ACCESOS-SOCIO-TURNOS-MI,
'T4' TO ACCESOS-SOCIO-TURNOS-JU,
'T5' TO ACCESOS-SOCIO-TURNOS-VI,
'T6' TO ACCESOS-SOCIO-TURNOS-SA,
'T7' TO ACCESOS-SOCIO-TURNOS-DO.
APPEND ACCESOS.
CLEAR ACCESOS.
MOVE: '45051' TO ACCESOS-SOCIO-NUMERO,
'RUTH PEÑA' TO ACCESOS-SOCIO-NOMBRE,
'0' TO ACCESOS-SOCIO-REPOSICION,
'T1' TO ACCESOS-SOCIO-TURNOS-LU,
'T2' TO ACCESOS-SOCIO-TURNOS-MA,
'T3' TO ACCESOS-SOCIO-TURNOS-MI,
'T4' TO ACCESOS-SOCIO-TURNOS-JU,
'T5' TO ACCESOS-SOCIO-TURNOS-VI,
'T6' TO ACCESOS-SOCIO-TURNOS-SA,
'T7' TO ACCESOS-SOCIO-TURNOS-DO.
APPEND ACCESOS.
ENDFORM.
FORM LLENA_ACCESOS *
FORM DESCARGA_XML *
FORM DESCARGA_XML.
DATA: L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
WRITE: / 'Converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'ACCESOS'
DATAOBJECT = ACCESOS[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
IF W_RC IS INITIAL.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
W_RC.
ENDIF.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = GK_RUTA
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM DESCARGA_XML *
Thanks & regards
Sreenivasulu P -
Error while generating an XML Document from XML Schema with JAXB
Hi,
I am following this OTN tutorial to generate the XML document from Java classes got from the XSD document.
http://www.oracle.com/technology/pub/notes/technote_jaxb.html
I am able to generate all the Java classes but getting error on compiling the XMLConstructor.java class which is use for generating the XML document :
I am using JDK 1.5 and
Oracle 10g XML Developer's Kit (XDK) Production for Java. xdk_nt_10_1_0_2_0_production
(though these are warnings I am not able to run it.)
Error
C:\Prototype\classes\jaxbderived\catalog>javac -Xlint XMLConstructor.java
warning: [path] bad path element "%CLASSPATH%": no such file or directory
XMLConstructor.java:42: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
journalList.add(journal);
^
XMLConstructor.java:46: warning: [unchecked] unchecked call to add(E) as a membe
r of the raw type java.util.List
articleList.add(article);
Thanks
Sanjeev ([email protected])Use JDK 1.4.
-
How to generate an XML Document from XQuery
The following query returns me the required XML output. However, I need to generate an XML Document out of it. How do I go about generating an XML Doc?.
SELECT XMLQuery('<Data>
{for $tert in ora:view("DATA"),
$tert_audit in ora:view("DATA_AUDIT")
let $tert_cmd_id := $tert/ROW/ID/text(),
$tert_spouse_name := $tert/ROW/SPOUSE_NAME/text(),
$tert_directions := $tert/ROW/DIRECTIONS/text(),
$tert_soil_zone := $tert/ROW/SOIL_ZONE/text(),
$tert_audit_cmd_id := $tert_audit/ROW/ID/text(),
$tert_audit_trans_date := $tert_audit/ROW/TRANSACTION_DATE/text()
where $tert_cmd_id = $tert_audit_cmd_id and
$tert_audit_trans_date >= xs:date(V_Last_Successful_Date)
order by $tert_cmd_id
return
<op>
<op_type>I</op_type>
<ent_id>{$tert_cmd_id}</ent_id>
<source>S</source>
<fg>
<val_flds>
<fld>
<id>spouse_name</id>
<val>{$tert_spouse_name}</val>
</fld>
<fld>
<id>directions</id>
<val>{$tert_directions}</val>
</fld>
<fld>
<id>soil_zone</id>
<val>{$tert_soil_zone}</val>
</fld>
</val_flds>
</fg>
</op>}</Data>' RETURNING CONTENT)
INTO V_Other_Insert
FROM dual;Hi Geoff,
I would like to generate an XML file which contains data as shown below:
<Insert>
<result>
<type>A</type>
<id>1</id>
<date>11/11/2006</date>
<source>Web</source>
</result>
</Insert>
I'm using the below given query for this purpose:
SELECT XMLQuery('<Insert>
{for $c in ora:view("TableA")
let $id := $c/ROW/ID/text(),
$code := $c/ROW/CODE/text(),
$type := $c/ROW/TYPE/text(),
$date := $c/ROW/DATE/text()
return
<result>
<type>{$type }</type>
<id>{$id}</id>
<date>{$date}</date>
<source>S</source>
</result> }</Insert>' RETURNING CONTENT)
INTO V_Insert
FROM dual;
V_Insert stores the required result.
How do I save this result to a XML Document?
Please help. -
Is it possible in java 5 to generate a XML document from object?
Hi all ,
Is it possible in java 5 to generate a XML document from object?if yes, how do I implement this?
~Regards: /\ P:^P would look better. ;)
0 0
>
U -
How do you include a DTD when generating an XML document
Hi
I have just started to use the Java XML Pack to generate a XML document.
How do you put the dtd element
<!DOCTYPE Controller SYSTEM "controller.dtd">
in the generated document.
I am using the following piece of code
public void generate(...)
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.newDocument();
Element rootElement = createElement("Controller");
// Fill out the nodes etc
// Save the result
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = Factory.newTransformer();
File f = new File("dummy.xml");
FileWriter fw = new FileWriter(f);
DOMSource d1 = new
DOMSource(rootElement,"controller.dtd");
StreamResult result = new StreamResult(fw);
transformer.transform(d1, result);
Thanks
GregHello,
I had to go through quite some pain to get this done about a year ago,anyways,here is the solution.
all the import files are in jaxp1.1 bundle.
below is a test class code.
import org.apache.crimson.tree.XmlDocument;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.*;
public class CreateDTDInXMLFile {
public CreateDTDInXMLFile() {
public static void main(String[] args) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element root = document.createElement("root");
Element name = document.createElement("name");
name.appendChild(document.createTextNode("Khalid"));
Element address = document.createElement("address");
address.appendChild(document.createTextNode("2022 11th Ave SW"));
root.appendChild(name);
root.appendChild(address);
document.appendChild(root);
((XmlDocument)document).write(System.out);
//the above will print the simple xml doc,now add the dtd
//suppose the dtd is [<!DOCTYPE root SYSTEM "address.dtd">]
((XmlDocument)document).setDoctype(null,"address.dtd",null);
//now print the xml doc again
System.out.println("\n");
((XmlDocument)document).write(System.out);
} catch(ParserConfigurationException pce) {
pce.printStackTrace();
return;
}catch (IOException ioe) {
ioe.printStackTrace();
This will take care of the agony..
Khalid -
How to generate nested xml from a resultset
there is a table which contains two field:key and fatherkey.
like this:
key fatherkey
node1 root
node2 node1
node3 node2
a tree can be builded from the table by recursion of key and fatherkey.
now I want to use this table to generate a xml buffer.
like this:
<nodes>
<node>
<key>node1</key>
<fkey>root</fkey>
<node>
<key>node2</key>
<fkey>node1</fkey>
<node>
<key>node3</key>
<fkey>node2</fkey>
</node>
</node>
</node>
</nodes>
if oracle special sql --"Connect by" can be used ,it is so easy.
but I can only use ansi sql.
how to generate the xml?hehe, I solved it by JDom!
source code is :
public StringBuffer loadInitResource()
Vector theOrphans = new Vector();
StringBuffer theInitRes = new StringBuffer();
Element root = new Element("NODES");
String xsql = "SELECT KEY,FATHERKEY FROM TABLE1";
ResultSete m_rs = stmt.executeQuery(xsql);
try{
while(m_rs.next())
Element theNode = new Element("NODE");
Element theFLD = new Element("ID");
theFLD.addContent(m_rs.getString(1));
theNode.addContent(theFLD);
theFLD = new Element("SID");
theFLD.addContent(m_rs.getString(2));
theNode.addContent(theFLD);
if("Root".equals(theNode.getChildText("SID").trim()))
root.addContent(theNode);
else if(x_setFatherRes(theNode, root))
System.out.println("find");
else
theOrphans.addElement(theNode);
Element theNode;
int nIndex;
boolean isDo = false;
while(theOrphans.size()>0)
System.out.println("find the orphan!");
isDo = false;
for(nIndex = 0;nIndex < theOrphans.size();nIndex++)
theNode = (Element) theOrphans.get(nIndex);
if(x_setFatherRes(theNode, root))
theOrphans.remove(nIndex);
isDo = true;
System.out.println("found the orphan!");
break;
if(!isDo)
System.out.println("some nodes could not be loaded!");
break;
//OutputStream out=new FileOutputStream("e:/XMLFile.xml");
Document doc = new Document(root);
XMLOutputter outputter = new XMLOutputter();
outputter.setEncoding("GB2312");
//outputter.output(doc,out);
theInitRes = new StringBuffer(outputter.outputString(doc));
catch(Exception e)
m_error += e.toString() ;
return theInitRes;
private boolean x_setFatherRes(Element theSon,Element theFather)
boolean isOK = false;
String sFatherSID = theFather.getChildText("ID");
if(sFatherSID != null)
if(theSon.getChildText("SID").equals(sFatherSID.trim()))
theFather.addContent(theSon);
isOK = true;
if(isOK)
return isOK;
Iterator iterator = theFather.getChildren().iterator();
while(iterator.hasNext())
Element theFather2 = (Element) iterator.next();
isOK = x_setFatherRes(theSon,theFather2);
if(isOK)
break;
return isOK;
enjoy it! -
Query to generate Nested XML feed
Hello,
I use Oracle 11g R2 SOE....
I have two main tables
COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number)
COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2)
Please, note the following has nothing to do with my problem:
CONTENT and MIMETYPE columns. Also, the lookup tables: PROJECTS , COM_TYPE
I Exposed a report as RESTful web service in XML format:
I am using this query to generate the XML 1 feed, but I need to tweak the query to generate XML 2 feed.
Is it possible, how to do it ???
Select
"COM"."COM_ID" as "COM_ID",
"COM"."COM_SIZE" as "SIZE",
"PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
"COM_TYPES"."COM_TYPE" as "COM_TYPE",
'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
FROM
COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
on IMG.COM_ID = COM.COM_ID
inner join "PROJECTS" "PROJECTS"
on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
inner join "COM_TYPE_LOOKUP" "COM_TYPES"
on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
WHERE
COM.COM_ID < 80 order by 1h1. XML 1
h2. Please look only at <COM_ID> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
</ROW>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</ROW>
</ROWSET>---------------------------
h1. XML 2
h2. Please look only at <COM_ID> and <Images> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</Images>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</Images>
</ROW>
</ROWSET>Hello,
I see, I found another solution, but come across another problem that is the web service should get Data from more than one table. I have this procedure, and I would like to *"UNION" its* Select Statement with another Select Statement:
declare
v_xml clob;
v_retval clob := '<?xml version="1.0" encoding="iso-8859-1"?>';
v_blob blob;
begin
select
xmlelement(
"LISTINGS",
xmlagg(
xmlelement(
"LISTING",
xmlforest(
'RS-'||R."RES_ID" as "Property_Ref_No",
"UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
'Sale' as "Ad_Type",
'Dubai' as "State",
L.LOCATION_NAME_EN AS "Community",
"PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
"RES_SALE"."ASKING_PRICE" as "Price",
' ' as "Frequency",
ST."SUB_TYPE" as "Unit_Model",
R."RES_SIZE" as "Unit_Builtup_Area",
R.BEDS as "Bedrooms",
R.bath as "No_of_Bathrooms",
"RES_SALE"."AD_TITLE" as "Property_Title",
RES_SALE.DESCRIPTION as "Web_Remarks",
to_char("RES_SALE"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
R.VIDEO as "Web_Tour",
select xmlagg(
xmlforest(
'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
FROM
IMAGES IMG
WHERE IMG.RES_ID = R.RES_ID ) Images )))).getclobval()
into v_xml
FROM
"RES_SALE" "RES_SALE"
inner join
RES R on (R."RES_ID"="RES_SALE"."RES_ID")
inner join
"UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_SALE"."RES_STATUS")
inner join
"PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
inner join
"UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
inner join
"RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
INNER JOIN
COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
INNER JOIN
LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
WHERE "RES_SALE".RES_status IN (5,8) AND "RES_SALE".LIVE = 'Y' AND "RES_SALE".DESCRIPTION IS NOT NULL
dbms_lob.append(v_retval,v_xml);
OWA_UTIL.Mime_Header('text/xml');
htp.p('Content-length: ' || to_char(dbms_lob.getlength(v_retval)));
htp.p('Content-Disposition: inline; filename="Just.xml"');
owa_util.http_header_close;
v_blob := wwv_flow_utilities.clob_to_blob(v_retval);
wpg_docload.download_file(v_blob);
end; h1. Select Statement that is needed to be "UNION-ED" with the Select Statement of the previous procedure:
select
xmlelement(
"LISTINGS",
xmlagg(
xmlelement(
"LISTING",
xmlforest(
'RR-'||R."RES_ID" as "Property_Ref_No",
"UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
'Rent' as "Ad_Type",
'Dubai' as "State",
L.LOCATION_NAME_EN AS "Community",
"PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
"RES_RENT"."ASKING_PRICE" as "Price",
' ' as "Frequency",
ST."SUB_TYPE" as "Unit_Model",
R."RES_SIZE" as "Unit_Builtup_Area",
R.BEDS as "Bedrooms",
R.bath as "No_of_Bathrooms",
"RES_RENT"."AD_TITLE" as "Property_Title",
"RES_RENT".DESCRIPTION as "Web_Remarks",
to_char("RES_RENT"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
R.VIDEO as "Web_Tour",
select xmlagg(
xmlforest(
'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
FROM
IMAGES IMG
WHERE IMG.RES_ID = R.RES_ID ) Images ))))
FROM
"RES_RENT" "RES_RENT"
inner join
RES R on (R."RES_ID"="RES_RENT"."RES_ID")
inner join
"UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_RENT"."RES_STATUS")
inner join
"PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
inner join
"UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
inner join
"RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
INNER JOIN
COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
INNER JOIN
LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
WHERE "RES_RENT".RES_status IN (5,8) AND "RES_RENT".LIVE = 'Y' AND "RES_RENT".DESCRIPTION IS NOT NULL -
Generating an xml document from SQLplus
Dear list,
We have over 240 database tables in our tablespace, which we would like to very quickly export to an xml file.
Is there any solution ?
regards
BenAre the xml documents stored in a XMLType column?
XMLType tables may be retrieved as XML.
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/transformxml/TransformXML.html
For tables with non-XMLType columns retrieve the document with XSU utility.
https://cwisdb.cc.kuleuven.ac.be/ora10doc/appdev.101/b10794/adx08xsu.htm#i1014723 -
How can i use a xsd while generating my xml document in oracle?
Hi, how can i use a xsd while building my xml document query, so i know the xml was built properly?
Cheers.Hi,
Do you want to validate your xml against xsd?
Read this
validating
There are some bugs also, for example xml is invalid but no errors when calling schemaValidate()
Ants -
SQL query to generate Nested XML
Hello,
I use Oracle 11g R2 SOE....
I have two main tables
COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number)
COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2)
Please, note the following has nothing to do with my problem:
CONTENT and MIMETYPE columns. Also, the lookup tables: PROJECTS , COM_TYPE
In APEX ( Application Express ) we can expose a report as RESTful web service in XML format:
I am using this query to generate the XML 1 feed, but I need to tweak the query to generate XML 2 feed.
Is it possible, how to do it ???
Select
"COM"."COM_ID" as "COM_ID",
"COM"."COM_SIZE" as "SIZE",
"PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
"COM_TYPES"."COM_TYPE" as "COM_TYPE",
'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
FROM
COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
on IMG.COM_ID = COM.COM_ID
inner join "PROJECTS" "PROJECTS"
on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
inner join "COM_TYPE_LOOKUP" "COM_TYPES"
on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
WHERE
COM.COM_ID < 80 order by 1h1. XML 1
h2. Please look only at <COM_ID> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
</ROW>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</ROW>
</ROWSET>---------------------------
h1. XML 2
h2. Please look only at <COM_ID> and <Images> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</Images>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</Images>
</ROW>
</ROWSET>Hi, Fateh
One possible way is to use XML functions to create your XML.
Using XML functions you can do the IMAGES as an XMLAGG subquery rather than join to the image table.
Here's an example using SCOTT schema:
SQL> select xmlelement(
2 "ROWSET"
3 , xmlagg(
4 xmlelement(
5 "ROW"
6 , xmlforest(
7 d.deptno as "ID"
8 , d.dname as "NAME"
9 , (
10 select xmlagg(
11 xmlelement(
12 "ImgUrl"
13 , 'http://the.server.com/'||e.empno
14 )
15 order by e.empno
16 )
17 from scott.emp e
18 where e.deptno = d.deptno
19 ) as "Images"
20 )
21 )
22 order by d.deptno
23 )
24 ) the_xml
25 from scott.dept d
26 /* joins to the other tables EXCEPT image table */
27 /
THE_XML
<ROWSET><ROW><ID>10</ID><NAME>ACCOUNTING</NAME><Images><ImgUrl>http://the.serverThat output is an XMLTYPE column (think of it as a CLOB with added functionality ;-) )
My SQL*PLUS cuts the output, but believe me, it is all there.
Just to show it, here's the same example wrapped in an XMLSERIALIZE function to pretty-print the XML:
SQL> select xmlserialize(
2 content
3 xmlelement(
4 "ROWSET"
5 , xmlagg(
6 xmlelement(
7 "ROW"
8 , xmlforest(
9 d.deptno as "ID"
10 , d.dname as "NAME"
11 , (
12 select xmlagg(
13 xmlelement(
14 "ImgUrl"
15 , 'http://the.server.com/'||e.empno
16 )
17 order by e.empno
18 )
19 from scott.emp e
20 where e.deptno = d.deptno
21 ) as "Images"
22 )
23 )
24 order by d.deptno
25 )
26 )
27 as varchar2(4000)
28 indent size=2
29 ) the_xml
30 from scott.dept d
31 /* joins to the other tables EXCEPT image table */
32 /
THE_XML
<ROWSET>
<ROW>
<ID>10</ID>
<NAME>ACCOUNTING</NAME>
<Images>
<ImgUrl>http://the.server.com/7782</ImgUrl>
<ImgUrl>http://the.server.com/7839</ImgUrl>
<ImgUrl>http://the.server.com/7934</ImgUrl>
</Images>
</ROW>
<ROW>
<ID>20</ID>
<NAME>RESEARCH</NAME>
<Images>
<ImgUrl>http://the.server.com/7369</ImgUrl>
<ImgUrl>http://the.server.com/7566</ImgUrl>
<ImgUrl>http://the.server.com/7788</ImgUrl>
<ImgUrl>http://the.server.com/7876</ImgUrl>
<ImgUrl>http://the.server.com/7902</ImgUrl>
</Images>
</ROW>
<ROW>
<ID>30</ID>
<NAME>SALES</NAME>
<Images>
<ImgUrl>http://the.server.com/7499</ImgUrl>
<ImgUrl>http://the.server.com/7521</ImgUrl>
<ImgUrl>http://the.server.com/7654</ImgUrl>
<ImgUrl>http://the.server.com/7698</ImgUrl>
<ImgUrl>http://the.server.com/7844</ImgUrl>
<ImgUrl>http://the.server.com/7900</ImgUrl>
</Images>
</ROW>
<ROW>
<ID>40</ID>
<NAME>OPERATIONS</NAME>
</ROW>
</ROWSET>For a webservice you do not need to pretty-print the XML that is returned by the webservice.
I do not know APEX, so I do not know if APEX supports exposing an allready built piece of XML rather than exposing a query result.
But my guess is that it should do it very nicely if you query an XMLTYPE datatype (that is - use the first of my examples rather than the pretty-printed one.)
If you can't get APEX to do it this way, then I suggest you try asking in the APEX forum rather than the SQL forum ;-) -
I have following tables :
DEPT
DEPT_ID DEPT_NAME GRP_NAME
1 Engineering Research and Development
2 Tool Design Research and Development
EMP
EMP_ID FIRST_NAME MIDDLE_NAME LAST_NAME DEPT_ID HIRE_DATE
1 Roberto Luc Tamburello 1 1997-12-12
2 Rob (null) Walters 2 1998-01-05
3 Thierry (null) D'Hers 2 1998-01-11
4 Janice B. Galvin 2 2001-01-23
EMP_TEL
EMP_ID TEL_ID
1 1
1 5
2 2
3 3
4 4
TEL
TEL_ID AREA_CODE PHONE_NO EXT TEL_TYPE_ID
1 111 1111111 111 1
2 222 2222222 222 1
3 333 3333333 333 1
4 444 4444444 444 1
5 555 5555555 (null) 2
TEL_TYPE
TEL_TYPE_ID TEL_TYPE_CD
1 OFFICE
2 FAX
3 CELLIs there a way to generate below xml in one sql statement?
<Company>
<Department>
<DepartmentName>Engineering</DepartmentName>
<GroupName>Research and Development</GroupName>
<Employee>
<FirstName>Roberto</FirstName>
<MiddleName>Luc</MiddleName>
<LastName>Tamburello</LastName>
<HireDate>1997-12-12</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>111-111-1111</TelephoneNumber>
<Extension>111</Extension>
</Telephone>
<Telephone>
<TelephoneType>FAX</TelephoneType>
<TelephoneNumber>555-555-5555</TelephoneNumber>
</Telephone>
</Employee>
</Department>
<Department>
<DepartmentName>Tool Design</DepartmentName>
<GroupName>Research and Development</GroupName>
<Employee>
<FirstName>Rob</FirstName>
<LastName>Walters</LastName>
<HireDate>1998-01-05</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>222-222-2222</TelephoneNumber>
<Extension>222</Extension>
</Telephone>
</Employee>
<Employee>
<FirstName>Thierry</FirstName>
<LastName>D'Hers</LastName>
<HireDate>1998-01-11</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>333-333-3333</TelephoneNumber>
<Extension>333</Extension>
</Telephone>
</Employee>
<Employee>
<FirstName>Janice</FirstName>
<MiddleName>B.</MiddleName>
<LastName>Galvin</LastName>
<HireDate>2001-01-23</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>444-444-4444</TelephoneNumber>
<Extension>444</Extension>
</Telephone>
</Employee>
</Department>
</Company>Is there a way to generate below xml in one sql statement?yes, this way:
SQL> select xmlelement("Company",
2 xmlagg(
3 xmlelement("Department",
4 xmlforest(dept_name as "DepartmentName",
5 grp_name as "GroupName"
6 ),
7 (select xmlagg(
8 xmlelement("Employee",
9 xmlforest(FIRST_NAME as "FirstName",
10 MIDDLE_NAME as "MiddleName",
11 LAST_NAME as "LastName",
12 to_char(HIRE_DATE,'yyyy-mm-dd') as "HireDate"
13 ),
14 (Select xmlagg(
15 xmlelement("Telephone",
16 xmlforest(TEL_TYPE_CD as "TelephoneType",
17 AREA_CODE||'-'||PHONE_NO as "TelephoneNumber",
18 EXT as "Extension"
19 )
20 )
21 )
22 from TEL t, TEL_TYPE tt, EMP_TEL et
23 where t.TEL_TYPE_ID=tt.TEL_TYPE_ID
24 and et.EMP_ID = e.EMP_ID
25 and et.TEL_ID = t.TEL_ID
26 )
27 )
28 )
29 from emp e
30 where e.DEPT_ID=d.DEPT_ID
31 )
32 )
33 )
34 ).extract('/*') doc
35 from DEPT d;
DOC
<Company>
<Department>
<DepartmentName>Engineering</DepartmentName>
<GroupName>Research and Development</GroupName>
<Employee>
<FirstName>Roberto</FirstName>
<MiddleName>Luc</MiddleName>
<LastName>Tamburello</LastName>
<HireDate>1997-12-12</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>111-1111111</TelephoneNumber>
<Extension>111</Extension>
</Telephone>
<Telephone>
<TelephoneType>FAX</TelephoneType>
<TelephoneNumber>555-5555555</TelephoneNumber>
</Telephone>
</Employee>
</Department>
<Department>
<DepartmentName>Tool Design</DepartmentName>
<GroupName>Research and Development</GroupName>
<Employee>
<FirstName>Rob</FirstName>
<LastName>Walters</LastName>
<HireDate>1998-01-05</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>222-2222222</TelephoneNumber>
<Extension>222</Extension>
</Telephone>
</Employee>
<Employee>
<FirstName>Thierry</FirstName>
<LastName>D'Hers</LastName>
<HireDate>1998-01-11</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>333-3333333</TelephoneNumber>
<Extension>333</Extension>
</Telephone>
</Employee>
<Employee>
<FirstName>Janice</FirstName>
<MiddleName>B.</MiddleName>
<LastName>Galvin</LastName>
<HireDate>2001-01-23</HireDate>
<Telephone>
<TelephoneType>OFFICE</TelephoneType>
<TelephoneNumber>444-4444444</TelephoneNumber>
<Extension>444</Extension>
</Telephone>
</Employee>
</Department>
</Company>Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/] -
Generate nested XML using OracleXMLQuery generates error
Hello,
I have oracle 8.1.6 with XSQL 1.0.4 and need to generate XML out of a query that contains the // init the OracleXMLQuery
OracleXMLQuery qry = new OracleXMLQuery(conn, query);
// shape the XML doc generated
qry.setMaxRows(2); // set the maximum number of rows to be returned
qry.setSkipRows(3); // numbers of rows to skipped
qry.setRowsetTag("MYDOC"); // set the tags encapsulating the whole doc
qry.setRowTag("RECORD"); // sets the row separator tag
qry.setRowIdAttrName("cnt"); // sets the id attribute of the row element
qry.useNullAttributeIndicator(true); // use attr. to indicate nullness
qry.useUpperCaseTagNames(); // use upper case tag names
qry.setErrorTag("ERR"); // tag for errors writen to XML doc
XMLDocument myXMLDocument = (XMLDocument)qry.getXMLDOM();
PrintWriter out = response.getWriter();
myXMLDocument.print(out);
out.close();nullI have exactly the same problem by using XSU.
If somebody solve it already ?
David, can you please provide more information or small example, how can I extract OracleConnection or Oracle Specific Driver inside the Weblogic App. Server and not generic weblogic.jdbc.rmi.SerialConnection instance.
I'm using Oracle thinDriver on Oracle8i.
Thank you in advance.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by David G:
have seen similar problems with wrapped jdbc driver being passed into Weblogic pool service and then cast back into OracleDriver after getting it back from Weblogic's JNDI DataSource lookup ...the Oracle extensions do not seem to survive Weblogic's jdbc pool services handling. I have gone over to running all my connection pools in Oracle's own namespace jdbc_access:// for JNDI lookups on DataSource pools instead. Much happier. <HR></BLOCKQUOTE>
null -
New to XML, need to generate XML document
I have an existing application that uses an Oracle 9.2.0.3 database. An existing PL/SQL procedure generates a flat file interface using UTL_FILE. My task is to upgrade this procedure to generate an XML file and transform this XML file into different outputs (e.g. flat file interface, PDF file which I plan to use XSL Formatting Objects). My question is how should I generate the XML document from the PL/SQL procedure? Should I use the Oracle 9i SQL/XML capabilities? specifically xmlelement, etc? An if so should I also use UTL_FILE to generate the XML file? Your help will be appreciated.
Williams,
Do you want to generate an XML file from the data present in relational tables using PL/SQL ?
In that case you can use XML SQL Utility(XSU).
For more information on XSU click [url http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96621/adx23xsp.htm#1008317]here.
Regards,
Anupama
[url http://otn.oracle.com/sample_code/]OTN Sample Code
Maybe you are looking for
-
Hp dv7-1245dx media smart button dont work
hi, i have a hp pavilion dv7-1245dx, i format de drive c and install the windows vista 64 in spanish because im in argentina, but before search and install all drivers,my media smart quik lunch button dont't work, I intall all drivers from the hp web
-
I Have updated to iOS 8 and iPhoto is dismissed. How can add a caption /title (not in the image) like I was used with iPhoto? Photos has not this feature. please, could anyone help me. I'm a real beginner. Thanks,
-
Is there a way to encrypt the password in the DAD file? If not then does Oracle plan to provide this feature in a future release?
-
Serious bug in Smart Web Page feature
I've lost an hour's work on a problem in Aperture 2, cannot solve it, and hope somebody here has seen the problem and can give me a workaround. In Aperture 2, I tagged approx 400 images with 2 keywords: "JV, varsity", then created a smart web page th
-
What is the business packages required for "plant maintenance"
hi experts, i got a business requirement how to show the plant maintenance module with the functionalities to show in the portal is ther any process is there or business packages required thanks and r