Generating XML through PL/SQL

Hi everyone,
I got a new task at work, and my task is to generate XML through PL/SQL.
I am using Oracle 11g database, and SQL Developer 3.0.
The purpose of this procedure is to upload xml file to a queue, so my BPEL process can access the queue and do what it does.
This is my first time writing a procedure that generates xml so bear with me.
Below is a sample of the xml file I received. I need to generate xml file below through PL/SQL. All the information in xml file will need to be retrieved from the database.
I need your help to start working on this procedure. Your help is very much appreciated.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body xmlns:ns1="http://www.ussc.gov/soa/casefile/event/types">
      <caseFileUploadEvent xmlns:xsi="http://www.w3XX.org/2001/XMLSchema-instance"
                           xsi:schemaLocation="http://www.XXXX.gov/soa/casefile/event/types ../xsd/Case_META.xsd"
                           xmlns="http://www.XXXX.gov/soa/casefile/event/types">
         <taskEvent>SUBMIT</taskEvent>
         <defendentDetails>
            <sentensingDate>2008-11-10-05:00</sentensingDate>
            <personDetails>
               <personNameDetails>
                  <firstName>FIRSTNAME</firstName>
                  <middleName>B</middleName>
                  <lastName>LASTNAME</lastName>
               </personNameDetails>
               <dateOfBirth>1969-09-23-04:00</dateOfBirth>
            </personDetails>
         </defendentDetails>
         <documentStatusDetails>
            <otherStatus>
               <intCode>61</intCode>
               <description>Other documents included</description>
            </otherStatus>
         </documentStatusDetails>
         <uploadOtherDetails>
            <submissionId>427000447</submissionId>               // NOTE: SUBMISSIONID WILL BE PASSED IN THROUGH THE PROCEDURE TO QUERY ALL THE INFORMATION NEEDED FOR THE XML FILE
            <submissionSessionId>401622</submissionSessionId>
            <submissionMethod>
               <intCode>1</intCode>
               <description>WebApplication</description>
            </submissionMethod>
            <submissionReason>
               <intCode>1</intCode>
               <description>InitialSubmission</description>
            </submissionReason>
            <district>
               <intCode>99</intCode>
               <description>Test District</description>
            </district>
            <caseFileType>
               <intCode>10</intCode>
               <description>Individual - Original</description>
            </caseFileType>
            <primaryDocketInfo>
               <yearYY>5</yearYY>
               <id>55555</id>
               <defendentNumber>555</defendentNumber>
            </primaryDocketInfo>
            <PACTSId>55555555</PACTSId>
            <AOJudgeId>
               <intCode>2512</intCode>
               <description>FABER, DAVID, A.</description>
            </AOJudgeId>
            <missingCasefile>false</missingCasefile>
            <creator>
               <firstName>will</firstName>
               <lastName>smith</lastName>
               <email>[email protected]</email>
               <actionDate>2005-09-07T09:48:09.811-04:00</actionDate>
            </creator>
            <lastModifier>
               <firstName>john</firstName>
               <lastName>doe</lastName>
               <email>[email protected]</email>
               <actionDate>2006-10-03T08:51:21.5-04:00</actionDate>
            </lastModifier>
         </uploadOtherDetails>
      </caseFileUploadEvent>
   </soap:Body>
</soap:Envelope>procedure below
procedure upload_process(submission_id number) as
begin
     -- retrieve information from database based on submission_id (passed in)
     -- generate XML
     -- send xml to queue
end upload_process;Thanks

Rooney,
First of all, I would use Oracle package UTL_DBWS to handle web service calls.
But if you choose to do all the work yourself to call web service, this is one of the options:
Since the size of your xml soap request is about 4k, you can just use pl/sql varchar2 variable to construct your xml.
Example:
cSoapRequest VARCHAR2(5000);
BEGIN
cSoapRequest := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                         <soap:Body xmlns:ns1="http://www.ussc.gov/soa/casefile/event/types">
                         <caseFileUploadEvent xmlns:xsi="http://www.w3XX.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://www.XXXX.gov/soa/casefile/event/types ../xsd/Case_META.xsd"
                         xmlns="http://www.XXXX.gov/soa/casefile/event/types">';
FOR recRow IN <your cursor> LOOP
    cSoapRequest := cSoapRequest || '<dateOfBirth>'|| TO_CHAR(recRow.DOB,'YYYY-MM-DD HH:MI' )|| '</dateOfBirth>';
END LOOP;
...Then use package utl_http to send the request and recieve response.
Google pl/sql webservice,
Here is one:
Calling Web Service from PL/SQL (ORA-31011: XML parsing failed)
Hope this will give you an idea.
Thomas

Similar Messages

  • How to generate XML file from SQL file !

    I am new to XML publisher. I known one way to generate XML file is register one report file in concurrent manager.
    But I want to generate XML file from sql file.
    Could someone show me how to code in sql file, how to register is in concurrent manager.
    Thanks !

    Hi
    Phew ... not sure we have the space here. So I can point you in the right direction:
    1. XML data generation - there are two packages in the db you can use with a plsql procedure, XMLGEN and SQL XML. You can also use java APIs too. Try checking the db documentation and search for the above methods.
    2. Registering the report - the system administrators guide will provide this info. Hooking the program up with XMLP is covered here - http://www.oracle.com/technology/products/applications/publishing/resource/CM%20Whitepaper5.0.pdf
    Regards, Tim

  • Generating xml using PL/SQL taking a lot of space in TEMP tablespace

    We wrote a stored procedure that generate xml which will be stored in a CLOB column. Environment is 9i on Windows 2003.
    The gnerated xml is about 800K. In the procedure there is one big cursor that will retrieve 200 records of 55 fields and many other small dynamic cursors that open and close here and there. The fields are pretty small. Biggest ones are like varchar2(30). The query for the big cursor does using union and need sorting.
    Can anyone explain why it takes about 15G of TEMP tablespace to accomplish this job and is there a way to avoid this?

    The version is Enterprise Edition 9.2.0.1.0.
    Below is the query.
    SELECT ROWNUM + ( SELECT NVL(MAX(WQX_ACTIVITY_GEN_ID), 0) FROM WQX_ACTIVITY ) as WQX_ACTIVITY_GEN_ID
         , A.ACTIVITYIDENTIFIER2            as ACTIVITY_IDENTIFIER
         , (SELECT MAX(O.ORGANIZATION_NAME) FROM SYS_ORGANIZATION O WHERE O.ORGANIZATION_ID = 111242)  as ORGANIZATION_NAME
         , (SELECT MAX(P.PROJECT_IDENTIFIER) FROM SYS_PROJECT P WHERE P.PROJECT_ID = 111242) as PROJECT_IDENTIFIER
         , A.ACTIVITYTYPECODE               as ACTIVITY_TYPE_CD
         , A.ActivityMediaName              as ACTIVITY_MEDIA_NAME
         , A.ActivityMediaSubDivisionName   as MEDIA_SUB_DIVISION
         , A.ActivityStartDate              as ACTIVITY_START_DATE
         , CASE WHEN A.ActivityStartTime is not NULL THEN
                     substr(A.ActivityStartTime,1,2)||':'||substr(A.ActivityStartTime,3,2)||':00'
                WHEN A.ActivityStartTime is NULL THEN ''
           END as ACTIVITY_START_TIME
    --   , substr(A.ActivityStartTime,1,2)||':'||substr(A.ActivityStartTime,3,2)||':00' as ACTIVITY_START_TIME
         , A.ACTIVITYENDDATE                as ACTIVITY_END_DATE
         , CASE WHEN A.ACTIVITYENDTIME is not NULL THEN
                     substr(A.ACTIVITYENDTIME,1,2)||':'||substr(A.ACTIVITYENDTIME,3,2)||':00'
                WHEN A.ACTIVITYENDTIME is NULL THEN ''
           END as ACTIVITY_END_TIME
    --   , substr(A.ACTIVITYENDTIME,1,2)||':'||substr(A.ACTIVITYENDTIME,3,2)||':00' as ACTIVITY_END_TIME
         , A.TIMEZONECODE1                  as TIME_ZONE_CD
         , A.ActivityRelativeDepthName      as RELATIVE_DEPTH_NAME
         , NULL                             as DEPTH_HEIGHT_MEASURE
         , NULL                             as DEPTH_HEIGHT_UNIT
         , 111242              as MONITORING_LOC_ID
         , A.ACTIVITYCOMMENTTEXT            as COMMENT_
         , A.SamplerName                    as SAMPLER_NAME
         , A.ActivityArea                   as ACTIVITY_AREA
         , A.ReportingRound                 as REPORTING_ROUND
         , A.SamplePanel                    as SAMPLEPANEL
         , A.DataIncludedinReport           as DATA_INCLUDED_IN_REPORT
         , A.FlowStatusIndicator            as FLOW_STATUS_IND
         , A.SampleChainOfCustody           as SAMPLE_COC
         , A.ActivitySeason                 as ACTIVITY_SEASON
         , A.RunoffImpact                   as RUNOFF_IMPACT
         , (111242)            as MONI_LOC_ID
         , (SELECT MAX(B.MONI_LOC_IDENTIFIER) FROM WQX_MONITORING_LOC B WHERE B.MONI_LOC_IDENTIFIER = A.MONITORINGLOCATIONIDENTIFIER) as MONI_LOC_IDENTIFIER
         , 111242                     as PROJECT_ID
         , NULL                             as BIO_ASSEMB_SAMPLED_NAME
         , NULL                             as BIO_TOXICITY_TEST_TYPE
         , A.METHODIDENTIFIER1              as SAMPLE_COLLECT_METHOD_IDENTIFI
         , A.METHODIDENTIFIERCONTEXT1       as SAMPLE_COLLECT_METHOD_CONTEXT
         , A.METHODNAME1                    as SAMPLE_COLLECT_METHOD_NAME
         , NULL                             as SAMPLE_COLLECT_QUALIFIER_TYPE
         , A.METHODDESCRIPTIONTEXT1         as SAMPLE_COLLECT_DESC
         , A.SampleCollectionEquipmentName  as SAMPLE_COLLECT_EQUIP_NAME
         , A.SAMPLECOLLECTIONEQUIPMENTTXT   as SAMPLE_COLLECT_EQUIP_DESC
         , A.METHODNAME2                    as SAMPLE_PREP_METHOD_NAME
         , A.METHODIDENTIFIER2              as SAMPLE_PREP_METHOD_IDENTIFIER
         , A.METHODIDENTIFIERCONTEXT2       as SAMPLE_PREP_METHOD_CONTEXT
         , NULL                             as SAMPLE_PREP_QUALIFIER_TYPE
         , A.METHODDESCRIPTIONTEXT1         as SAMPLE_PREP_DESC
         , A.SampleContainerTypeName        as SAMPLE_CONTAINER_TYPE
         , A.SampleContainerColorName       as SAMPLE_CONTAINER_COLOR
         , A.ChemicalPreservativeUsedName   as CHEM_PRESERVATIVE_USED
         , A.ThermalPreservativeUsedName    as THERMAL_PRESERVATIVE_USED
         , A.SAMPLETRANSPORTSTORAGEDESC     as SAMPLE_TRANS_STORAGE
         , A.AnalysisStartTime              as AnalysisStartTime
         , A.AnalysisEndTime                as AnalysisEndTime
         , A.MethodSpeciationName           as MethodSpeciationName
         , A.ResultLaboratoryCommentCode    as ResultLaboratoryCommentCode
         , A.UnidentifiedSpeciesIdentifier  as UnidentifiedSpeciesIdentifier
      FROM TMP_CHEMACTIVITYRESULTS A
    WHERE A.SUBMISSION_ID = 111242
       AND A.ACTIVITYIDENTIFIER2 NOT IN
         ( SELECT ACTIVITY_IDENTIFIER FROM WQX_ACTIVITY )
    UNION
    SELECT X.WQX_ACTIVITY_GEN_ID                                             as WQX_ACTIVITY_GEN_ID
         , A.ACTIVITYIDENTIFIER2                                             as ACTIVITY_IDENTIFIER
         , (SELECT MAX(O.ORGANIZATION_NAME) FROM SYS_ORGANIZATION O WHERE O.ORGANIZATION_ID = 111242)  as ORGANIZATION_NAME
         , (SELECT MAX(P.PROJECT_IDENTIFIER) FROM SYS_PROJECT P WHERE P.PROJECT_ID = 111242) as PROJECT_IDENTIFIER
         , NVL(A.ACTIVITYTYPECODE, (SELECT MAX(ACTYP_CD) FROM REF_ACTIVITY_TYPE WHERE TO_CHAR(ACTYP_UID) = TO_CHAR(X.ACTIVITY_TYPE_CD))) as ACTIVITY_TYPE_CD
         , NVL(A.ActivityMediaName, X.ACTIVITY_MEDIA_NAME)                   as ACTIVITY_MEDIA_NAME
         , NVL(A.ActivityMediaSubDivisionName, X.MEDIA_SUB_DIVISION)         as MEDIA_SUB_DIVISION
         , NVL(A.ActivityStartDate, TO_CHAR(X.ACTIVITY_START_DTTM, 'YYYY-MM-DD')) as ACTIVITY_START_DATE
         , CASE WHEN A.ActivityStartTime is not NULL THEN
                     substr(A.ActivityStartTime,1,2)||':'||substr(A.ActivityStartTime,3,2)||':00'
                WHEN A.ActivityStartTime is NULL THEN ''
           END as ACTIVITY_START_TIME
    --   , NVL((substr(A.ActivityStartTime,1,2)||':'||substr(A.ActivityStartTime,3,2)||':00'), TO_CHAR(X.ACTIVITY_START_DTTM, 'HH24:MI:SS')) as ACTIVITY_START_TIME
         , NVL(A.ACTIVITYENDDATE, TO_CHAR(X.ACTIVITY_END_DTTM, 'YYYY-MM-DD'))     as ACTIVITY_END_DATE
         , NVL(A.ACTIVITYENDDATE, TO_CHAR(X.ACTIVITY_END_DTTM, 'HH24:MI:SS'))     as ACTIVITY_END_TIME
         , NVL(A.TIMEZONECODE1, X.TIME_ZONE_CD)                              as TIME_ZONE_CD
         , NVL(A.ActivityRelativeDepthName, X.RELATIVE_DEPTH_NAME)           as RELATIVE_DEPTH_NAME
         , X.DEPTH_HEIGHT_MEASURE                                            as DEPTH_HEIGHT_MEASURE
         , X.DEPTH_HEIGHT_UNIT                                               as DEPTH_HEIGHT_UNIT
         , NVL(111242, X.MONITORING_LOC_ID)                     as MONITORING_LOC_ID
         , NVL(A.ACTIVITYCOMMENTTEXT, X.COMMENT_)                            as COMMENT_
         , NVL(A.SamplerName, X.SAMPLER_NAME)                                as SAMPLER_NAME
         , NVL(A.ActivityArea, X.ACTIVITY_AREA)                              as ACTIVITY_AREA
         , NVL(A.ReportingRound, X.REPORTING_ROUND)                          as REPORTING_ROUND
         , NVL(A.SamplePanel, X.SAMPLEPANEL)                                 as SAMPLEPANEL
         , NVL(A.DataIncludedinReport, X.DATA_INCLUDED_IN_REPORT)            as DATA_INCLUDED_IN_REPORT
         , NVL(A.FlowStatusIndicator, X.FLOW_STATUS_IND)                     as FLOW_STATUS_IND
         , NVL(A.SampleChainOfCustody, X.SAMPLE_COC)                         as SAMPLE_COC
         , NVL(A.ActivitySeason, X.ACTIVITY_SEASON)                          as ACTIVITY_SEASON
         , NVL(A.RunoffImpact, X.RUNOFF_IMPACT)                              as RUNOFF_IMPACT
         , (111242)                                             as MONI_LOC_ID
         , (SELECT MAX(B.MONI_LOC_IDENTIFIER) FROM WQX_MONITORING_LOC B WHERE B.MONI_LOC_IDENTIFIER = A.MONITORINGLOCATIONIDENTIFIER) as MONI_LOC_IDENTIFIER
         , 111242                                                      as PROJECT_ID
         , X.BIO_ASSEMB_SAMPLED_NAME                                         as BIO_ASSEMB_SAMPLED_NAME
         , X.BIO_TOXICITY_TEST_TYPE                                          as BIO_TOXICITY_TEST_TYPE
         , NVL(A.METHODIDENTIFIER1, X.SAMPLE_COLLECT_METHOD_IDENTIFI)        as SAMPLE_COLLECT_METHOD_IDENTIFI
         , NVL(A.METHODIDENTIFIERCONTEXT1, X.SAMPLE_COLLECT_METHOD_CONTEXT)  as SAMPLE_COLLECT_METHOD_CONTEXT
         , X.SAMPLE_COLLECT_METHOD_NAME                                      as SAMPLE_COLLECT_METHOD_NAME
         , X.SAMPLE_COLLECT_QUALIFIER_TYPE                                   as SAMPLE_COLLECT_QUALIFIER_TYPE
         , NVL(A.METHODDESCRIPTIONTEXT1, X.SAMPLE_COLLECT_DESC)              as SAMPLE_COLLECT_DESC
         , NVL(A.SampleCollectionEquipmentName, X.SAMPLE_COLLECT_EQUIP_NAME) as SAMPLE_COLLECT_EQUIP_NAME
         , NVL(A.SAMPLECOLLECTIONEQUIPMENTTXT, X.SAMPLE_COLLECT_EQUIP_DESC)  as SAMPLE_COLLECT_EQUIP_DESC
         , NVL(A.METHODNAME2, X.SAMPLE_PREP_METHOD_NAME)                     as SAMPLE_PREP_METHOD_NAME
         , NVL(A.METHODIDENTIFIER2, X.SAMPLE_PREP_METHOD_IDENTIFIER)         as SAMPLE_PREP_METHOD_IDENTIFIER
         , NVL(A.METHODIDENTIFIERCONTEXT2, X.SAMPLE_PREP_METHOD_CONTEXT)     as SAMPLE_PREP_METHOD_CONTEXT
         , X.SAMPLE_PREP_QUALIFIER_TYPE                                      as SAMPLE_PREP_QUALIFIER_TYPE
         , NVL(A.METHODDESCRIPTIONTEXT1, X.SAMPLE_PREP_DESC)                 as SAMPLE_PREP_DESC
         , NVL(A.SampleContainerTypeName, X.SAMPLE_CONTAINER_TYPE)           as SAMPLE_CONTAINER_TYPE
         , NVL(A.SampleContainerColorName, X.SAMPLE_CONTAINER_COLOR)         as SAMPLE_CONTAINER_COLOR
         , NVL(A.ChemicalPreservativeUsedName, X.CHEM_PRESERVATIVE_USED)     as CHEM_PRESERVATIVE_USED
         , NVL(A.ThermalPreservativeUsedName, X.THERMAL_PRESERVATIVE_USED)   as THERMAL_PRESERVATIVE_USED
         , NVL(A.SAMPLETRANSPORTSTORAGEDESC, X.SAMPLE_TRANS_STORAGE)         as SAMPLE_TRANS_STORAGE
         , NVL(A.AnalysisStartTime, '')                                      as AnalysisStartTime
         , NVL(A.AnalysisEndTime, '')                                        as AnalysisEndTime
         , NVL(A.MethodSpeciationName, '')                                   as MethodSpeciationName
         , NVL(A.ResultLaboratoryCommentCode, '')                            as ResultLaboratoryCommentCode
         , NVL(A.UnidentifiedSpeciesIdentifier, '')                          as UnidentifiedSpeciesIdentifier
      FROM TMP_CHEMACTIVITYRESULTS A
           JOIN WQX_ACTIVITY X ON A.ACTIVITYIDENTIFIER2 = X.ACTIVITY_IDENTIFIER
    WHERE A.SUBMISSION_ID = 111242;

  • Generating XML using PL/SQL

    hi All,
    We have an interface across two different applications in an organisation. Data is ported across these two application in a flat file which has specific format. These files are generated using generic pro c programs. Now we are planning to replace these files with XML. Also to replace generic pro c with PL/SQL to generate and read XML files. Now my question is, whether using PL/SQL to generate/read XML file will be faster than generating/reading flat files using pro c? Will the performance improve significantly? If anybody has worked on this, your inputs will be valuable.
    Thanks in advance. Hoping to hear something veru soon from the masters.
    Regards,
    Rajesh

    hi All,
    We have an interface across two different applications in an organisation. Data is ported across these two application in a flat file which has specific format. These files are generated using generic pro c programs. Now we are planning to replace these files with XML. Also to replace generic pro c with PL/SQL to generate and read XML files. Now my question is, whether using PL/SQL to generate/read XML file will be faster than generating/reading flat files using pro c? Will the performance improve significantly? If anybody has worked on this, your inputs will be valuable.
    Thanks in advance. Hoping to hear something veru soon from the masters.
    Regards,
    Rajesh

  • Why it's so inefficient to generate XML from SQL queries?

    I am learning to use Oracle9i XML DB to generate XML document using SQL queries. According to the document, there are multiple ways to do it (SQLX, DBMS_XMLGEN, SYS_XMLGEN, XSU). I am using SQLX to do it, but find it's so inefficient. Could someone point out what could be the problem?
    I generate XML from TPC-H database, using the query as shown below. The indexes and primary key/foreign keys are created and specified. The system is Pentium IV 2GHz, Linux 2.4.18 with 512MB memory and 1GB swap. With database size 5MB, it spends about 300 seconds (TKPROF result) to generate the XML document. But for 10MB TPCH database, I cannot get the xml document after a long time. I find that all almost physical memory are used up by it. Therefore I stop it.
    It seems that nested-loop join is used to evaluate the query, therefore it's very inefficient. I don't know whether there is a efficient way to do it.
    Wish to get your help. Thank you very much!
    Chengkai Li
    ===================================================================================================================
    SELECT XMLELEMENT (
    "region",
    XMLATTRIBUTES ( r_regionkey AS "regionkey", r_name AS "name", r_comment AS "comment"),
    (SELECT XMLAGG(
    XMLELEMENT (
    "nation",
    XMLATTRIBUTES ( n_nationkey AS "nationkey", n_name AS "name", n_regionkey AS "regionkey", n_comment AS "comment"),
    XMLConcat ((SELECT XMLAGG(XMLELEMENT (
    "supplier",
    XMLATTRIBUTES ( s_suppkey AS "suppkey", s_name AS "name", s_address AS "address", s_nationkey AS "nationkey", s_phone AS "phone", s_acctbal AS "acctbal", s_comment AS "comment"),
    (SELECT XMLAGG(XMLELEMENT (
    "part",
    XMLATTRIBUTES ( p_partkey AS "partkey", p_name AS "name", p_mfgr AS "mfgr", p_brand AS "brand", p_type AS "type", p_size AS "size", p_container AS "container", p_retailprice AS "retailprice", p_comment AS "comment", ps_availqty AS "ps_availqty", ps_supplycost AS "ps_supplycost", ps_comment AS "ps_comment")))
    FROM PART p, PARTSUPP ps
    WHERE ps.ps_partkey = p.p_partkey
    AND ps.ps_suppkey = s.s_suppkey
         FROM SUPPLIER s
    WHERE s.s_nationkey = n.n_nationkey
    (SELECT XMLAGG(XMLELEMENT(
    "customer",
    XMLATTRIBUTES ( c_custkey AS "custkey", c_name AS "name", c_address AS "address", c_nationkey AS "nationkey", c_phone AS "phone", c_acctbal AS "acctbal", c_mktsegment AS "mktsegment", c_comment AS "comment"),
    (SELECT XMLAGG(XMLELEMENT (
    "orders",
    XMLATTRIBUTES ( o_orderkey AS "orderkey", o_custkey AS "custkey", o_orderstatus AS "orderstatus", o_totalprice AS "totalprice", o_orderdate AS "orderdate", o_orderpriority AS "orderpriority", o_clerk AS "clerk", o_shippriority AS "shippriority", o_comment AS "ps_comment"),
    (SELECT XMLAGG(XMLELEMENT (
    "lineitem",
    XMLATTRIBUTES ( l_orderkey AS "orderkey", l_partkey AS "partkey", l_suppkey AS "suppkey", l_linenumber AS "linenumber", l_quantity AS "quantity", l_extendedprice AS "extendedprice", l_discount AS "discount", l_tax AS "tax", l_returnflag AS "returnflag", l_linestatus AS "linestatus", l_shipdate AS "shipdate", l_commitdate AS "commitdate", l_receiptdate AS "receiptdate", l_shipinstruct AS "shipinstruct", l_shipmode AS "shipmode", l_comment AS "comment")
    FROM LINEITEM l
    WHERE l.l_orderkey = o.o_orderkey
    FROM ORDERS o
    WHERE o.o_custkey = c.c_custkey
         FROM CUSTOMER c
    WHERE c.c_nationkey = n.n_nationkey
    FROM NATION n
    WHERE n.n_regionkey = r.r_regionkey
    FROM REGION r;

    Tim,
    Oracle Reports was the orginal way to do this in an Oracle Apps environment. However, the XML Publisher team built a tool called data templates to do this as well. You can read several articles on how to use data templates on the XMLP blog. Here's the first arcticle in a series: http://blogs.oracle.com/xmlpublisher/2006/11/08#a127.
    Bryan

  • Generating reports from PL/SQL

    I'm new to the world of BI Publisher - so far I'm impressed with what I've seen. I've managed to create a report and an RTF template and generate some nice looking PDF's :)
    What I need to do now is to have a nightly job that produces PDF shipment reports using my template for all new shipments generated during the day and I'm having a little difficulty putting it all together.
    I've looked at the BI Publisher API's that allow me to generate an XSL from my RTF template and the using the FO engine merge the XSL and XML data to produce the PDF. Then using the delivery manager API's I can send these reports out via email.
    I'm a little unsure of how to get the XML source - I've played around with the DataEngine API to generate XML from a SQL query so I think that's where I should be heading.
    Does this all sounds right ? Ideally, I want to be able to do all of this from within a scheduled PL/SQL job every night but all the interaction with the BI server seems to be via Java.
    Is there an easy(ish) way to run all of this from within PL/SQL ?
    And should I be going about this by:
    1/ generate XML data using dataengine API
    2/ create an RTF template using word and the xml data generated above
    3/ use the RTF processor to generate an XSL-FO from my RTF template
    (1-3 will only need to be done once)
    4/ Then my nightly job will use the dataengine to generate new shipment XML data
    5/ use FO processor to generate PDF's from each
    6/ use delivery manager API's to email out
    All sounds very cumbersome and intense -is there no easier way ?! :) Also, I'm thinking i should be using the bursting engine to split one query containing all the new shipment data and generate/mail a PDF for each shipment ? Is that necessary if all going to the same email address ?
    Help/guidance/suggestions greatly appreciated !
    Many thanks,
    Brent

    repost .... Has anyone successfully called BIP web services from within the database using Java stored procedures ?
    Still struggling to work out how to generate my reports from PL/SQL ! :((

  • Generate XML directly from Oject-Relational data

    I have just installed Oracle 9.2 on Win2000
    What do I need to install in order to use SQLX functions that generates XML within regular SQL queries from a relational DB
    for example :
    SELECT e.employee_id,
    XMLELEMENT("Employee",XMLATTRIBUTES (e.employee_id),
    XMLELEMENT("Name",e.first_name||' '|| e.last_name),
    XMLELEMENT("Hire-Date",e.hire_date)) AS "employee-name"
    FROM employees e
    Thanks,

    Hi Amit,
    You should be able to write the SQLX Query that you have mentioned with db version 9.2 onwards. Is there any problem you are encountering in getting the required result.
    If you can point out the problem then we can possibly help.
    -shefali

  • Generate XML Urgent !!!!!

    Hi all,
    i have just problem with generating XML through database.
    my code is
    DECLARE
    XML_DATA XMLTYPE;
    BEGIN
    FOR v_cur IN (SELECT * FROM EMPLOYEES)
    LOOP
    SELECT dbms_xmlgen.getxmltype('SELECT * FROM EMPLOYEES WHERE EMP_ID=' || v_cur.EMP_ID)
    INTO XML_DATA
    FROM DUAL;
    INSERT INTO TEST_DATA VALUES (XML_DATA);
    END LOOP;
    END;
    NOW i am getting out put like
    <Rowset>
    <Row>
    <emp_id>101<emp_id>
    <emp_name>King</emp_name>
    <add1>160-2</add1>
    <add2>Apex Appartment</add2>
    <dept_id>10</dept_id>
    <city>NJ</city>
    </Row>
    </Rowset>
    But i want out put in following format :
    <Rowset>
    <Row>
    <emp_id>101<emp_id>
    <emp_name>King</emp_name>
    <Address>
    <add1>160-2</add1>
    <add2>Apex Appartment</add2>
    </Address>
    <dept_id>10</dept_id>
    <city>NJ</city>
    </Row>
    </Rowset>
    also tell me if column has NULL value the only node disply like <add2></add2>( this is not mandatory)
    please help me out
    Thanks in advance

    Here is a way to do it:
    declare
    XML_DATA XMLTYPE;
    BEGIN
    FOR v_cur IN (SELECT * FROM emp)
    LOOP
    SELECT dbms_xmlgen.getxmltype('select empno, ename, xmlforest (job, mgr) as ADDRESS from emp WHERE empno=' || v_cur.empno)
    INTO XML_DATA
    FROM DUAL;
    INSERT INTO TEST_DATA VALUES (XML_DATA);
    END LOOP;
    END;
    /change the emp to employees, and list out all the columns you want to include in xml.
    in xmlforest (job, mgr), replace job, mgr columns to the columns you want to include in address segment.
    Thanks
    Edited by: PhoenixBai on Aug 23, 2010 11:16 PM

  • Xml file not generated through Pl/sql procedure as a concurrent executable

    Hi,
    I getting error while genarating xml file through Pl/sql procedure as a concurrent executable file.
    Error Message:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource

    Hi,
    Make sure the file has the XML header:
    <?xml version="1.0" encoding="UTF-8"?>
    or similar.
    Regards,
    Gareth
    Blog: http://garethroberts.blogspot.com/

  • How to generate XML from relational data : PL/SQL or Java

    I'm new to Oracle XML and would appreciate some advice. I've been asked to generate XML documents from data stored in relational tables. The XML documents must be validated against a DTD. We will probably want to store the XML in the database.
    I've seen a PL/SQL based approach as follows :
    1.Mimic the structure of the DTD using SQL object types 2.Assign the relational data to the object type using PL/SQL as required
    3.Use the SYS_XMLGEN package to render the required XML documents from the SQL objects
    However, creating the object types seems to be quite time consuming (step 1 above) for anything other than the simplest of XML documents.
    I've also seen that there is the Java based approach, namely :
    1. Use the XML generator to build Java classes based on a DTD.
    2. Use these classes to build the required XML
    On the face of it, the Java based approach seems simpler. However, I'm not that familiar with Java.
    Which is the best way to proceed ? Is the PL/SQL based approach worth pursuing or should I bite the bullet and brush up my Java ?
    Is it possible to use a combination of PL/SQL and Java to populate the dtd generated java classes (step 2 of the Java approach) to reduce my learning curve ?
    Thanks in advance

    To help answer your questions:
    1) Now, in 9iR2, you can use SQL/XML as another choice.
    2) You can also use XSU to generate the XML and use XSLT to transform it to a desired format instead of using object views if possible.
    3) XDK provide Class generator support to populate XML data to Java classes.

  • How to generate XML from SQL query

    possible ways to generate XML from SQL qury.
    i want to generate XML of following query. "Select * from emp,dep wher emp.deptno=dept.deptno"

    Hello.
    Can you try:
    SQL> set pages 0
    SQL> set linesize 150
    SQL> set long 9999999
    SQL> set head off
    SQL> select dbms_xmlgen.getxml('Select * from emp,dep wher emp.deptno=dept.deptno') from dual;
    It works fine for me.
    Octavio

  • Submitting XML Publisher Concurrent Program through PL/SQL

    Hi,
    I am trying to submit a XML Publisher concurrent program through PL/SQL API fnd_request.submit_request.
    The request gets fired and completes successfully but it doesn't pick up the default template attached to it. Its output is plain XML but expected output is PDF report.
    However when I submit this report from SRS, it picks up the default template and gives output in PDF.
    Please let me know what could be going wrong?
    Regards,
    Nitin

    Check out the FND_REQUEST.ADD_LAYOUT API. You need to call it before you submit your report.
    Cheers,
    Dave

  • Error while generating XML file through RDF

    Hi,
    I wanted to generate a Report on some business case. For that I need to generate XML file first.
    For generating XML file
    1. I have built an RDF through Reports builder.
    2. Saved the report to local machine with extension .rdf
    3. Moved it to appltop/app/reports/US directory
    4. Registered tha Report with Executable of type Oracle Reports
    5. Defined Concurrent Program with OUTPUT as XML.
    When I submmitted the program, it was giving an error as follows.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    A semi colon character was expected. Error processing resource 'https://oaphrd.humana.com/OA_CGI/FNDWRR.exe?temp_id=2088989...
    +<?xml version="1.0" encoding="&Encoding"?>+
    But, when I tried to sane the report directly to a file (file - > generate file -> XML) the XML was generated successfully.
    How to get rid of this. Some one please help me out.
    Thanks !
    Edited by: Rajasekhar Reddy on May 4, 2012 1:23 AM

    Hi,
    I found the issue and corrected it. :)
    This was happened only because of the Version problem of Report Builder with Oracle Applications.
    Reports Builder 10g is not compatiblie with Oracle Applications 11.5.10.
    Oracle 11.5+ will always expect the RDF from Reports 6i version. Because of this, the endocing was damaged.
    You can observe in the earlier post as encoding="&Endoding". Here +&Encoding should be replaced by some encoding mechanism like "UTF-8".+
    Finally corrected the version and got the Output as expected.
    Thanks !

  • How to Validate XML against XSD through PL/SQL?

    Hi friends,
    I m new to this forum. This is my first query.
    In our project, we are trying to generate output XML using PL/SQL procedure. I have done that successfully. Now my problem is I have to validate this against our XSD. How will I do that? Can you provide me with a sample example.
    Thanks to all in advance.
    Regards,
    apk

    Have you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.

  • PL/SQL to generate XML compliant with an XSD

    Please excuse me if this has been asked elsewhere. I'm trying on Oracle 9.2 to output XML that will comply with a predefined schema. I've started out by creating various object types and an object view that matches the xml schema definition, and can use dbms_xmlgen.getxml to get out an xml document (a clob) without trouble, BUT I need to post-process this with shell scripts to add on the namespace information and amend the tags to put in the (e.g.) ns3: bit to identify which is the target namespace. It seems odd that I should need to do this - is there a better way? I have trawled all over rthe place but cannot find any mention of this requirement. Thanks for any help you might give me, I'm new to xml.

    Okay forget that, here's a quote from Oracle:
    "I'm the PM for XML DB, and our preferred direction for generating XML from data stored in relational tables is the industry standard SQL/XML operators. DBMS_XMLGEN will continue to be supported but most of our development efforts in terms of performance / feature improvements willl be targetted at the SQL/XML operators (XMLELEMENT(), XMLATTRIBUTES(), XMLAGG(), XMLFOREST() etc). In general they have proven to be much more flexible and performant, and easier to use "
    So it seems that the object-type/view route is dead in the water. Shame.

Maybe you are looking for

  • WRT54G as Access Point & Intermittent Connectivity

    So I followed the advice found here http://forums.linksys.com/linksys/board/message?board.id=Wireless_Routers&message.id=26177 Hooking up a wired router to my WRT54G Router, which I am trying to use as an access point. I've set my LAN IP to 192.168.1

  • Defining column for chart category values

    Problem I want to produce a chart from a table imported from Excel. The data imported perfectly but since the X axis values (just a series of years) are in a column Numbers appears to treat them as another data series, this situation is compounded by

  • Camera stopped working in photobooth and iChat

    Hi, I don't know if this is the right forum or not...I just bought a MacBook a few weeks ago and the camera worked fine until a few days ago, the little green light on the right side of the camera is always on, but the camera doesn't seem to be worki

  • Messages signs out of AIM/Bonjour after inactivity

    after upgrade to 10.8 messages signs me out (AIM + Bonjour) when computer is inactive for short period. in 10.7 it would set me to away - for minutes or for hours - made now difference. now it logs me out completely and i have to wait to sign back an

  • Photoshop cs6 slow

    since upgrading to Mountain Lion OS X, everything I click on I get the loading wheel? I haven't used photoshop since