XML using PL-SQL

Hi All,
I am trying to use XML for building an application. Is it
possible to generate page by only using a PL-SQL?
I know how to generate XML by using PL-SQL.
--How can I apply XSL document to it?
Thanks,
Samir

The XML Developers kit available on this site at: http://technet.oracle.com/tech/xml/
contains utilities for parsing XML with PL/SQL and other methods.

Similar Messages

  • 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

  • Generate connections.xml using only sql commands

    Hello,
    I have a database, where all connection information (Hostname, User, Port, SID, etc.) are stored for several databases. Now I want to create the connections.xml which I can import to the SQL Developer. The idea is to administer the connection information in a single point. Then anyone can query and import the connections easily to the SQL Developer.
    The structure itself was easy to understand and implement using XMLELEMENT. My Problem is, how can I save the password respectively how is the password encrypted? I have found several tools that can decode the password, but I have the plaintext. I found a solution using Jython, but I want to use only SQL. There should be a suitable algorithm in the dbms_crypto package, I hope. I don´t want to use other tools or languages.
    Thanks for help,
    Frank
    Edited by: frank_nillies on 20.03.2013 04:28
    - renamed connection.xml to connections.xml

    Hello,
    I have a database, where all connection information (Hostname, User, Port, SID, etc.) are stored for several databases. Now I want to create the connections.xml which I can import to the SQL Developer. The idea is to administer the connection information in a single point. Then anyone can query and import the connections easily to the SQL Developer.
    The structure itself was easy to understand and implement using XMLELEMENT. My Problem is, how can I save the password respectively how is the password encrypted? I have found several tools that can decode the password, but I have the plaintext. I found a solution using Jython, but I want to use only SQL. There should be a suitable algorithm in the dbms_crypto package, I hope. I don´t want to use other tools or languages.
    Thanks for help,
    Frank
    Edited by: frank_nillies on 20.03.2013 04:28
    - renamed connection.xml to connections.xml

  • Remove the unnecessary tags in XML using PL/SQL

    Hi Friends
    from the below XML, its generate by a complex SQL query, Now we need to remove all the object type tags, and all the empty tags.
    Version - PL/SQL Release 11.2.0.3.0 - Production
    <MajorLine>
        <MAJOR_LINE_OBJECT_TYPE> -- Need to remove these Objects types showing in the XML
            <LINEID>143424538</LINEID>
            <ITEMNAME>TC-ABC-123</ITEMNAME>
            <ITEMPATH>78245</ITEMPATH>
            <QUANTITY>10</QUANTITY>
            <SERVICELINE/> -- Need to remove all the Empty tags
            <MINORLINE>
                <MINOR_LINE_OBJECT_TYPE> -- Need to remove these Objects types showing in the XML
                    <LINEID>143424799</LINEID>
                    <ITEMNAME>TCC-abc</ITEMNAME>
                    <ITEMPATH>78245</ITEMPATH>
                    <QUANTITY>10</QUANTITY>
                    <SERVICELINE/>-- Need to remove all the Empty tags
                    <MINOR_MINOR_LINES>
                        <M_MINOR_LINE_TYPE> -- Need to remove these Objects types showing in the XML
                            <LINEID>143424798</LINEID>
                            <ITEMNAME>SF15-abc-xyz</ITEMNAME>
                            <ITEMPATH>78245</ITEMPATH>
                            <QUANTITY>10</QUANTITY>
                      </M_MINOR_LINE_TYPE>-- Need to remove these Objects types showing in the XML
                    </MINOR_MINOR_LINES>
                </MINOR_LINE_OBJECT_TYPE>--Need to remove these Objects types showing in the XML
            </MINORLINE>
        </MAJOR_LINE_OBJECT_TYPE>-- Need to remove these Objects types showing in the XML
    </MajorLine>
    i tried one of the queries posted in this blog ,PFB  to remove the empty tags , but it didnt work for me unfortunately. Please help.
    PFB
    WITH sample_data AS (
      SELECT xmltype('<MajorLine>
        <MAJOR_LINE_OBJECT_TYPE>
            <LINEID>143424538</LINEID>
            <ITEMNAME>hijk</ITEMNAME>
            <ITEMPATH>78245</ITEMPATH>
            <QUANTITY>10</QUANTITY>
            <SERVICELINE/>
            <MINORLINE>
                <MINOR_LINE_OBJECT_TYPE>
                    <LINEID>143424799</LINEID>
                    <ITEMNAME>efg</ITEMNAME>
                    <ITEMPATH>78245</ITEMPATH>
                    <QUANTITY>10</QUANTITY>
                    <SERVICELINE/>
                    <MINOR_MINOR_LINES>
                        <M_MINOR_LINE_TYPE>
                            <LINEID>143424798</LINEID>
                            <ITEMNAME>abc</ITEMNAME>
                            <ITEMPATH>78245</ITEMPATH>
                            <QUANTITY>10</QUANTITY>
                        </M_MINOR_LINE_TYPE>
                    </MINOR_MINOR_LINES>
                </MINOR_LINE_OBJECT_TYPE>
            </MINORLINE>
        </MAJOR_LINE_OBJECT_TYPE>
    </MajorLine>') xmldoc
      FROM dual
    SELECT deleteXML( t.xmldoc
                    , '/MajorLine/*[.="" or contains(.,"?")]'
                    ) as result
    FROM sample_data t
    My email ID is [email protected] -- You can reach me
    thanks in advance ... Arun thomas T

    Hey Odie. Great to see you again, the query is
    SELECT XMLELEMENT (
              "MajorLine",
              major_line_object_type (
    oola_major.line_id,
    oola_major.ordered_item,
    oola_major.header_id,
    oola_major.ordered_quantity,
                 CAST (
                    MULTISET (
                       SELECT oola_ser.line_id,
    oola_ser.ordered_item,
    --oola_ser.header_id,
    oola_ser.ordered_quantity,
    CAST (
                                 MULTISET (
    SELECT oola_ser2.service_start_date,
    oola_ser2.service_end_date,
    oola_ser2.service_duration
                                      FROM oe_order_lines_all oola_ser2
                                     WHERE oola_major.line_id =
    oola_ser2.service_reference_line_id
                                           AND oola_ser2.header_id =
    oola_major.header_id) AS service_period_table_type)
    FROM oe_order_lines_all oola_ser
                        WHERE oola_major.line_id =
                                 oola_ser.service_reference_line_id
    AND oola_ser.header_id = oola_major.header_id) --As of now excluding cross order service line
    AS SERVICE_TABLE_TYPE),
                 CAST (
                    MULTISET (
                       SELECT oola_minor.line_id,
    oola_minor.ordered_item,
    oola_minor.header_id,
    oola_minor.ordered_quantity,
    CAST (
                                 MULTISET (
                                    SELECT oola_ser1.line_id,
    oola_ser1.ordered_item,
                                           -- oola_ser1.header_id,
    oola_ser1.ordered_quantity,
                                           CAST (
                                              MULTISET (
                                                 SELECT oola_ser3.
    service_start_date,
    oola_ser3.
    service_end_date,
    oola_ser3.
    service_duration
                                                   FROM oe_order_lines_all oola_ser3
                                                  WHERE oola_minor.line_id =
    oola_ser3.
    service_reference_line_id
    AND oola_ser3.header_id =
    oola_major.
    header_id) AS service_period_table_type)
                                      FROM oe_order_lines_all oola_ser1
                                     WHERE oola_minor.line_id =
    oola_ser1.service_reference_line_id
                                           AND oola_ser1.header_id =
    oola_major.header_id) --As of now excluding cross order service line
    AS SERVICE_TABLE_TYPE),
    CAST (
                                 MULTISET (
                                    SELECT oola_minor_m.line_id,
    oola_minor_m.ordered_item,
                                           oola_minor_m.header_id,
    oola_minor_m.ordered_quantity
                                      FROM oe_order_lines_all oola_minor_m
                                     WHERE oola_minor.line_id =
                                              oola_minor_m.link_to_line_id
                                           AND oola_minor_m.header_id =
    oola_major.header_id) --As of now excluding cross order service line
                                                                       AS m_minor_line_table_type)
    FROM oe_order_lines_all oola_minor
                        WHERE    --oola_minor.top_model_line_id=oola_major.line_id
    oola_minor.link_to_line_id = oola_major.line_id
    AND oola_minor.header_id = oola_major.header_id
    AND oola_minor.item_type_code != 'SERVICE') AS MINOR_LINE_TABLE_TYPE)))
              AS "XMLOutput"
      FROM oe_order_lines_all oola_major
    WHERE oola_major.line_id = 143424538 AND oola_major.link_to_line_id IS NULL;
    can we rewirte it to get the desired out put ..
    Desired output is Just remove the Object_type tags and empty tags coming in the output xml.
    The previous issues i mentioned are not solved yet  . actually will update the challenges ..
    Odie .. thanks.. again

  • 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;

  • XML Generation using a sql query in an efficient way -Help needed urgently

    Hi
    I am facing the following issue while generating xml using an sql query. I get the below given table using a query.
         CODE      ID      MARK
    ==================================
    1 4 2331 809
    2 4 1772 802
    3 4 2331 845
    4 5 2331 804
    5 5 2331 800
    6 5 2210 801
    I need to generate the below given xml using a query
    <data>
    <CODE>4</CODE>
    <IDS>
    <ID>2331</ID>
    <ID>1772</ID>
    </IDS>
    <MARKS>
    <MARK>809</MARK>
    <MARK>802</MARK>
    <MARK>845</MARK>
    </MARKS>
    </data>
    <data>
    <CODE>5</CODE>
    <IDS>
    <ID>2331</ID>
    <ID>2210</ID>
    </IDS>
    <MARKS>
    <MARK>804</MARK>
    <MARK>800</MARK>
    <MARK>801</MARK>
    </MARKS>
    </data>
    Can anyone help me with some idea to generate the above given CLOB message

    not sure if this is the right way to do it but
    /* Formatted on 10/12/2011 12:52:28 PM (QP5 v5.149.1003.31008) */
    WITH data AS (SELECT 4 code, 2331 id, 809 mark FROM DUAL
                  UNION
                  SELECT 4, 1772, 802 FROM DUAL
                  UNION
                  SELECT 4, 2331, 845 FROM DUAL
                  UNION
                  SELECT 5, 2331, 804 FROM DUAL
                  UNION
                  SELECT 5, 2331, 800 FROM DUAL
                  UNION
                  SELECT 5, 2210, 801 FROM DUAL)
    SELECT TO_CLOB (
                 '<DATA>'
              || listagg (xml, '</DATA><DATA>') WITHIN GROUP (ORDER BY xml)
              || '</DATA>')
              xml
      FROM (  SELECT    '<CODE>'
                     || code
                     || '</CODE><IDS><ID>'
                     || LISTAGG (id, '</ID><ID>') WITHIN GROUP (ORDER BY id)
                     || '</ID><IDS><MARKS><MARK>'
                     || LISTAGG (mark, '</MARK><MARK>') WITHIN GROUP (ORDER BY id)
                     || '</MARK></MARKS>'
                        xml
                FROM data
            GROUP BY code)

  • Xml in pl/sql

    i want 2 create an xml using pl/sql. oracle web agent must be installed and and xml utilities for pl/sql
    im using win2000 and im connected to ora8.1.6
    in linux. where do i need to install this 2 software. in the server or in my client pc?
    thanks in advance.
    regards
    jerome

    You should install the XML SQL Utility for PL/SQL in your database. It is basically a set of JAVA classes that get loaded into the database. You will use the PL/SQL packages to access the methods on these classes. You should use the DBMS_XMLQUERY and DBMS_XMLSAVE packages.
    You can run the install from your client.

  • Using a SQL data source and XML data source in the same template

    I am trying to develop a template for the Request for Quote report generated in Apps 11.5.10. I have loaded the data from the XML output into the template, but I am missing one field - I need the org_id from the po_headers table. Is it possible to use a sql data source (i.e., "select org_id from po_headers_all where po_header_id = [insert header_id from xml data]...") in addition to the xml data source to populate the template at runtime? When you use the Insert > SQL functionality is it static at the time the template is created, or does it call to the database at runtime? I've looked through all the docs I could find, but this isn't clear.
    Thanks for any help or suggestions you may have.
    Rhonda

    Hi Pablo
    Thats a tough one ... if you go custom with a data template you will at least get support on the data template functionality ie you have a problem when you try and build one. You will not get support on the query inside the data template as you might have gotten with the Oracle Report, well you could at least log a bug against development for a bad query.
    Eventually that Oracle Report will be converted by development anyway, theres an R12 project going on right now to switch the shipped OReports to data templates. AT this point you'll be fully supported again but:
    1. You have to have R12 and
    2. You'll need to wait for the patch
    On reflection, if you are confident enough in the query then Oracle will support you on its implementation within a data template. Going forward you may be able to swap out your DT and out in the Oracle one without too much effort.
    Regards, Tim

  • Validating XML with XML Schema using PL/SQL

    Hello,
    I have XSD file and a example XML file.
    Using pl/sql how I can validate the example XML is valid for XSD file?
    Thanks in advance.
    Bakul
    Message was edited by:
    bakulesh

    Have you looked at this documentation, Transforming and Validating XMLType Data

  • Parse an Aggregate in XML Document using PL/SQL

    Hi. I've been successful with parsing a TAG in XML Document stored in CLOB using PL/SQL XML Parser.
    However, I need help on how to get the whole aggregate in XML Document stored in CLOB.
    sample XML Doc :
    <library>
    <book>
    <title>Oracle Complete Reference</title>
    <author>Kevin</Author>
    <year>2000</year>
    </book>
    <video>
    <title>Learning C++</title>
    <length>2 hours</length>
    <video>
    </library>
    I need a function that will accept an Input which is the aggregate name and will return the aggregate value.
    With the sample XML above, say the input is 'VIDEO', the function will return :
    <video>
    <title>Learning C++</title>
    <length>2 hours</length>
    <video>
    I'll really appreciate any help.
    null

    I used such an example to parse several Varchar2 strings in a given DB session:
    BEGIN
    parser := xmlparser.newparser ;
    xmlparser.parsebuffer(parser,xmlout) ;
    domdoc := xmlparser.getDocument(parser) ;
    xmlparser.FREEPARSER(parser) ;
    parser.id := -1 ;
    nodes := xslprocessor.selectNodes(
    xmldom.makenode(domdoc),
    'Positionen/Position') ;
    for i in 1 .. xmldom.getLength(nodes) loop
    node := xmldom.item(nodes,i-1) ;
    -- do s/thing with the node
    end loop ;
    xmldom.freedocument(domdoc) ;
    RETURN(komponenten) ;
    EXCEPTION
    WHEN OTHERS THEN
    if parser.id <> -1 then xmlparser.freeparser(parser) ;
    end if ;
    if domdoc.id <> -1 then xmldom.freedocument(domdoc) ;
    end if ;
    RAISE ;
    END ;
    However, after about 2000 of nodes lists parsed, I get an ArrayIndexOutOfBoundsException from XMLNodeCover. Obviously, I should release the nodes or the nodelist, but I have not found any procedure to do this.
    Pascal

  • Could we use embedded SQL for XML in .pc ?

    Hi,
    Can we use embedded SQL for XML in .pc ?
    <1> assume we have run SQL statements in Oracle9i:
    SQL>create table MY_XML_TABLE
    (Key1 NUMBER,
    Xml_Column SYS.XMLTYPE);
    SQL>insert into MY_XML_TABLE(key1, Xml_Column) values
    (1, SYS.XMLTYPE.CREATEXML
    ('<book>
    <chapter num="1">
    <text>This is the my text</text>
    </chapter>
    <book>')
    <2> Could we directly translate it in .pc as usually:
    <outlined, not exactly)
    int emp_number = 1;
    XML_Data emprec; /* ?????? */
    EXEC SQL SELECT M.Xml_Column.GETCLOBVAL() as XML_Data
    INTO :emprec INDICATOR :emprec_ind
    FROM MY_XML_TABLE M
    WHERE Key1 = :emp_number;
    Thanks
    MJ

    reply by myself.
    No problem!!
    ===============================
    int emp_number = 1;
    struct emprec{
    char feature[1280]
    EXEC SQL SELECT M.Xml_Column.GETCLOBVAL() as XML_Data
    INTO :emprec INDICATOR :emprec_ind
    FROM MY_XML_TABLE M
    WHERE Key1 = :emp_number;

  • BPEL process to Insert XML into DB using pl/sql stored proc

    Hi,
    We have created a BPEL process in which we are taking input request and store it into Oracle Database using PL/SQL proc.
    We have been unsuccessful in doing so because the data stored in table has root element missing.
    Has any body done this (insert xml into DB using pl/sql stored proc) successfully ?
    We can so this successfully if we do not use stored procedure and store data directly in table.
    Regards

    I have done this, stored it as a CLOB.
    Also I received the payload as an opaque schema, so I had to convert the message from binary into string.
    This way the root element doesn't get removed.
    cheers
    James

  • Write / store xml data in Xe and retrieve stored data using pl/sql

    Hi to all,
    i'm searching a tutorial on:
    A - how to write / store xml data in Xe and retrieve stored data using pl/sql
    I don't want to use other technologies, because i use htmldb and my best practice is with pl/sql.
    I was reading an ebook (quite old maybe) however it's about oracle 9 and it's talking about xmltype:
    1 - I don't understand if this is a user type (clob/varchar) or it's integrated in Oracle 9 however i will read it (it's chapter 3 titled Using Oracle xmldb).
    Please dont'reply here: i would be glad if someone can suggest me a good tutorial / pdf to achieve task A in Oracle XE.
    Thanx

    Thank you very much Carl,
    However my fault is that i've not tried to create the table via sql plus.
    Infact i was wrong thinking that oracle sql developer allows me to create an xmltype column via the create table tool.
    however with a ddl script like the following the table was created successfully.
    create table example1
    keyvalue varchar2(10) primary key,
    xmlcolumn xmltype
    Thank you very much for your link.
    Message was edited by:
    Marcello Nocito

  • Generating XML using Varray or Pl/SQL table

    I am trying to convert an old plsql procedure to generate XML data. The program is getting all the data to report from various sources to a pl/sql table.
    Is there any way to directly convert data into xml from plsql table ??
    Here is the plsql table defination
    TYPE Emp_rec IS RECORD ( Batch_name VARCHAR2(240)
    ,Employee_name VARCHAR2(240)
    ,Employee_number VARCHAR2(240)
    ,Element_name VARCHAR2(240)
    ,Bee_value NUMBER
    ,Ele_scr_value NUMBER
    TYPE emp_data IS TABLE OF Emp_rec
    INDEX BY BINARY_INTEGER;
    E emp_data;
    And i am trying to get xml using following code:
    FOR i IN E.FIRST.. E.LAST
    LOOP
    SELECT
    XMLConcat (
    XMLELEMENT(
    "batch",
    XMLFOREST(
    E(i).Batch_name AS "Batch_name",
    E(i).Employee_number AS "Employee_number",
    E(i).Element_name AS "Element_name"
    INTO l_xml
    FROM dual;
    end loop;
    I am not sure whether this can actually be done or not. I have option to write the xml file manually to output ; but just wondering whether this method of getting xml is correct or not ? If yes, then how can we use plsql table data and merge it into a single XML file
    Please let me know your views and opinions.
    Thanks
    Ankur

    I am trying to convert an old plsql procedure to generate XML data. The program is getting all the data to report from various sources to a pl/sql table.
    Is there any way to directly convert data into xml from plsql table ??
    Here is the plsql table defination
    TYPE Emp_rec IS RECORD ( Batch_name VARCHAR2(240)
    ,Employee_name VARCHAR2(240)
    ,Employee_number VARCHAR2(240)
    ,Element_name VARCHAR2(240)
    ,Bee_value NUMBER
    ,Ele_scr_value NUMBER
    TYPE emp_data IS TABLE OF Emp_rec
    INDEX BY BINARY_INTEGER;
    E emp_data;
    And i am trying to get xml using following code:
    FOR i IN E.FIRST.. E.LAST
    LOOP
    SELECT
    XMLConcat (
    XMLELEMENT(
    "batch",
    XMLFOREST(
    E(i).Batch_name AS "Batch_name",
    E(i).Employee_number AS "Employee_number",
    E(i).Element_name AS "Element_name"
    INTO l_xml
    FROM dual;
    end loop;
    I am not sure whether this can actually be done or not. I have option to write the xml file manually to output ; but just wondering whether this method of getting xml is correct or not ? If yes, then how can we use plsql table data and merge it into a single XML file
    Please let me know your views and opinions.
    Thanks
    Ankur

  • How to iterate xml elements using PL/SQL

    Hello,
    Let's say I have the following xml:
    <A>
    <B name="b1">
    </B>
    <B name="b2">
    </B>
    </A>
    I would like to iterate over the B and sub-B elements using PL/SQL?
    Any help will be appreciated.

    Hi,
    You can use 'PL/SQL DOM API for XMLType (DBMS_XMLDOM)'
    to work with XML. You can check the example present at
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96620/xdb08pls.htm#1041419
    to check how it does.
    The API for the package DBMS_XMLDOM is given on the same page(http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96620/xdb08pls.htm#1040676)
    You can use them for your requirement.
    Regards,
    Anupama

Maybe you are looking for