Display sql output in xml format

Hi,
We are using Oracle 9i. I want to display output of a sql query as xml format.
I noticed EXTRACT function in SQL does this. Can anyone please explain XMLType instance and XPath string parameters of this function.
All of my table columns are NUMBER/VARCHAR2 data types and the table is also NOT a XML Type. Please let me know the solution.
Thanks.

SQL> select dbms_xmlquery.getxml('select * from scott.emp where rownum < 3') from dual ;
DBMS_XMLQUERY.GETXML('SELECT*FROMSCOTT.EMPWHEREROWNUM<3')
<?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <EMPNO>7369</EMPNO>
      <ENAME>SMITH</ENAME>
      <JOB>CLERK</JOB>
      <MGR>7902</MGR>
      <HIREDATE>12/17/1980 0:0:0</HIREDATE>
      <SAL>800</SAL>
      <DEPTNO>20</DEPTNO>
   </ROW>
   <ROW num="2">
      <EMPNO>7499</EMPNO>
      <ENAME>ALLEN</ENAME>
      <JOB>SALESMAN</JOB>
      <MGR>7698</MGR>
      <HIREDATE>2/20/1981 0:0:0</HIREDATE>
      <SAL>1600</SAL>
      <COMM>304</COMM>
      <DEPTNO>30</DEPTNO>
   </ROW>
</ROWSET>
1 row selected.
SQL> select XMLType(dbms_xmlquery.getxml('select * from scott.emp where rownum < 3')).extract('/ROWSET/ROW[@num = "2"]/ENAME/text()').getStringVal() from dual ;
XMLTYPE(DBMS_XMLQUERY.GETXML('SELECT*FROMSCOTT.EMPWHEREROWNUM<3')).EXTRACT('/ROWSET/ROW[@NUM="2"]/ENAME/TEXT()').GETSTRINGVAL()
ALLEN
1 row selected.
SQL>

Similar Messages

  • Can we generate the output of SQL Query in XML format ..

    Hi Team,
    Can we generate an XML doc for an SQL Query.
    I've seen in SQL Server 2000.It is generating the output of an SQL Query in xml format.
    select * from emp for xml auto
    The output looks like
    <emp EMPNO="7369" ENAME="SMITH" JOB="CLERK" MGR="7902" HIREDATE="1980-12-17T00:00:00" SAL="2800" DEPTNO="20"/><emp EMPNO="7370" ENAME="SMITH" JOB="CLERK" MGR="7902" HIREDATE="1980-12-17T00:00:00" SAL="2800" DEPTNO="10"/>

    Just a little bit of short hand.
    Get the XML out of your database, via HTTP
    Of course the easiest method is just to return an XMLType from a stored procedure and let the calling routine figure out what to do with it. Instead
    of that way though, I'll show you how to do it via HTTP. It's all completely built into 10g and is super easy to use.
    CREATE OR REPLACE VIEW emps_and_depts AS
    SELECT e.employee_id AS "EmployeeId",
    e.last_name AS "Name",
    e.job_id AS "Job",
    e.manager_id AS "Manager",
    e.hire_date AS "HireDate",
    e.salary AS "Salary",
    e.commission_pct AS "Commission",
    XMLFOREST (
    d.department_id AS "DeptNo",
    d.department_name AS "DeptName",
    d.location_id AS "Location"
    ) AS "Dept"
    FROM employees e, departments d
    WHERE e.department_id = d.department_id
    Some people hear web and immediately start salivating about security issues. Let me address that quickly. Just because you have the HTTP and/or
    FTP servers running in the database, that does not mean you have a security problem. For one, I would hope your databases are behind a firewall.
    Second, with the correct architecture (DMZ, app servers, etc) you can make this data available outside the firewall fairly transparently and third,
    just because it's on the web does not mean the data MUST be available on the internet. This is a good way to make your data available on your
    intranet. If you are worried about people INSIDE your firewall, that still doesn't preclude web based access. Follow Oracle security guidelines.
    Before I show you how to get to your data, let's talk about URLs and URIs. A URL is a Uniform Resource Locater and URI is a Uniform Resource
    Identifier. A URL is the way you would identify a document on the net, i.e. http://www.oracle.com is a URL. A URI is a more generic form of a URL.
    Oracle supports three types of URI: HTTPURIType - basically a URL (which would be like the URL above), XDURIType - a pointer to an XDB resource
    (usually an XML document but can be other objects), and DBURIType - a pointer to database objects.
    It's the DBURIType that we're going to concentrate on here. The DBURIType let's us reference database objects using a file/folder paradigm. The
    format for a DBURI is /oradb/<schema>/<table>. Oradb is shorthand for the database; it is not the database name or SID. My database is named XE
    but I still use oradb in the DBURI. For example, the view we created above is in my XE database, is owned by HR (at least in my case) and is called
    EMPS_AND_DEPTS. This can be referenced as /oradb/HR/EMPS_AND_DEPTS.
    If the view had many rows and you wanted only one of them, you can restrict it by including a predicate. The documentation for XDB has a great
    write up on Using DBURIs.In our case, we are going to write out the entire document. Now that you understand that the DBURI is a pointer to
    objects in our instance, we can use that to access the data as a URL.
    The format for the URL call is http://<machinename>:<port>/<DBURI>
    In my case, my XE database is running on a machine called mach1 and is listening on port 8080. So to see the view we created above, I open my
    browser and navigate to: http//mach1:8080/oradb/HR/EMPS_AND_DEPTS
    The created URL will be as http//mach1:8080/oradb/PUBLIC/EMPS_AND_DEPTS
    If your database is set up correctly and listening on port 8080 (the default), your browser should ask you to login. Login as the user who created the
    view (in my case HR). You should now get an XML document displayed in your browser.
    And that's it. It doesn't get much simpler than that. If you get rid of the descriptive text above, it basically comes down to:
    Create a table or view
    Open your web browser
    Enter a URL
    Enter a user ID and password
    View your XML
    If you notice, Oracle formatted the data as XML for us. Our view returns scalar columns and an XML fragment called Dept. Oracle formatted the
    return results into an XML format.
    And as a side note, if you look closely, you'll see that my URL has PUBLIC where I said to put HR. PUBLIC is a synonym for all objects that your
    logged in user can see. That way, if your user has been granted select access on many schemas, you can use PUBLIC and see any of them.

  • Report output in XML format

    Is it possible to save (or export) report output in XML format, it is ok with either WebI or DeskI report, here we are concerned about output format not what type of report we can use to produce the output in XML format.
    Thank you,
    Srini

    Hi Srinivas,
    Only options available in WEBI or DESKI is to save documents in Excel or PDF format.
    As a workaround you can use Excel as an intermediate between your WEBI or DESKI document to XML format.
    When you try to save WEBI document in XML Data format you may get following Error because the Excel sheet does not contain any XML format that requires.
    u201CCan Not save XML data because the workbook does not contain any XML mappingsu201D
    Solution:
    1. Excel cannot save all or part of your workbook as XML Data if you have not created one or more mapped ranges.
    2. If you haven't added an XML map to your workbook, or your data is not contained within an XML list, then you can save your workbook in the XML Spreadsheet file format.
    If you have added an XML map to your workbook, follow these steps to map XML elements to your worksheet:
    1. On the Data menu, point to XML, and then click XML Source to open the XML Source task pane.
    2. To map one or more elements to your worksheet, select the elements in the XML Source task pane. To select nonadjacent elements, click one element, and then hold down CTRL and click each element.
    3. Drag the selected elements to the worksheet location where you want them to appear.
    I Hope this helps to find  the path of solution with Ease.
    Thanks...
    Pratik

  • Can anybody tell me the way of getting Smartform output as xml format??

    Dear Experts,
    Can anybody tell me the way of getting Smartform output as xml format??
    Is there exists a standard way of getting it?
    Regards,
    Nikhil Jain

    Hi,
    Use function module FB_DOWNLOAD_FORM .
    Provide your form name as input for i_formname.
    you will get the output in xml format.
    or use utilities--> download option for downloading in xml format.
    For your referrence:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0b6bc290-0201-0010-5b87-a0e7c7eb55d0?quicklink=index&overridelayout=true
    May it helps you.
    Regards.
    DS

  • Display Report output in Matrix format

    Hi
      I want to display normal report output in somewhat this manner.
    I will have one change requrest number and many transport requests will be assigned to that change request number, and to the transport requests many objects will be assigned.
    I have to display the output in this format:
    Change Request 1  |   Tr No.1 |  Tr No.2 |  Tr No.1 | and so on....
    Obj1
    Obj2
    Obj3
    Change Request 1  |   Tr No.1 |  Tr No.2 |  Tr No.1 | and so on....
    Obj1
    Obj2
    Obj3
    Like this it should go on.
    I have done the coding part, how to display the data in the above format i am not getting any idea, please help me out if you have any ideas.
    Thanks & Regards
    Haritha.

    Hi Vijay,
      First of all thank you for the response.
    I am retrieving the data from different tables and putting all the data in one internal table called i_final. Below is the declaration of that internal table and how i have populated the data to that. I am using control break statements to display the data but the data is coming in the next line.
    Please see the final internal table:
    1. Declaration:
    Data:Begin of i_final occurs 0,
           ccsnr like ysts-ccsnr,
           trkorr like ysts-trkorr,
           obj_name like e071-obj_name,
           check_box(1),
           status LIKE YSCS-STATUS,
          End of i_final.
    2. Populating different internal tables data to this table:
      loop at i_ccno.
        i_final-ccsnr = i_ccno-ccsnr.
        i_final-trkorr = i_ccno-trkorr.
        read table i_status with key trkorr = i_ccno-trkorr.
        if sy-subrc = 0.
          i_final-status = i_status-status.
        endif.
        read table i_obj_name with key trkorr = i_ccno-trkorr.
        if sy-subrc = 0.
          i_final-obj_name = i_obj_name-obj_name.
        endif.
        append i_final.
        clear i_final.
      endloop.
    3. Using Control break statements to display the data.
      sort i_final by ccsnr.
      loop at i_final.
         at new ccsnr.
           write:/2 i_final-ccsnr.
         endat.
           write:20 i_final-trkorr.
           uline.
      endloop.
    But the output is coming like this:
    CHG0003785  HSDK933109
                          HSDK933111
                          HSDK933113
                          HSDK933143
                          HSDK933268
    But i want the output like this:
    CHG0003785 | HSDK933109  |  HSDK933111  |   HSDK933113
    Thanks & Regards
    Haritha.

  • How to regenerate output in XML format after having assigned RTF Template

    1. I created a concurrent request to get the output in XML data format
    2. Having created RTF File and assigned Data Definition and Template through XML Administartor Responsibility
    3. Now I want to make changes in Data Definition XML File, However I need to get the output file in XML data format, However Concurrent Request is not allowing me to get the XML output because Template is already assigned for the output and not able to de-assign template file from concurrent request.
    For some reason in XML publisher, the end date for Template is disable, I am not able to update end date for template.
    Is there any way to create an output in XML format through concurrent request after Template File is assigned to create an output? I will appreciate your help.

    This is for people who want to know more in detail. Problem is if you put end date then you have to recreate an entry and then have to go through the same process. However I have found a way to use the same file,
    Get the template_id by running the following query
    select * from xdo_templates_b
    where template_code = 'TEMPLATE_CODE'
    Run the following query to update the end_date to some previous date value
    update xdo_templates_b
    set end_date = to_date('6/9/2011','mm/dd/yyyy')
    where template_id = 162
    After that when you run request through concurrent request, it will not show the default template assigned to concurrent request. Run the request, output will be created in XML format.
    Run the following query to use the template again
    update xdo_templates_b
    set end_date = null
    where template_id = 162
    Edited by: user9941374 on Jun 10, 2011 9:20 AM

  • Download script Output to XML format

    Dear friends,
    I want to download script output to xml format.
    Can you please help me regarding this issue.
    Its very Urgent.....
    Regards,
    Munna.G

    hi krishna,
    In Smartforms
    goto UTILITIES ---> download form.
    Browse the location and save the form.
    The saved form is in xml format.
    If you want to use that form,
    create a new form and go to utilities--> upload
    OR:
    Use function module FB_DOWNLOAD_FORM .
    Provide your form name as input for i_formname.
    you will get the output in xml format
    i think this will help u
    reward if help ful
    regards,
    sindhu.

  • Concurrent request submission displays Output in xml format ?

    Hi ,
    I am submitting a concurrent request from workflow which is an xml publisher report . my problem when the program is run individually it displays the output correctly in rtf format but when the same request is submitted from worklfow the output comes in xml format ?
    What could be the problem ?
    I am using the standard submission "FND_WF_STANDARD.SUBMITCONCPROGRAM " program and assigning the values directly to it . the submission activity is working fine but the output comes as mentioned above.
    Regards,
    Skg

    Kiran ,
    I am not using fnd_request.submit request coc I don't need to capture the user information for my workflow .
    I am only using the standard " FND_WF_STANDARD.SUBMITCONCPROGRAM " . this Package only submits the concurrent program through workflow in a function.
    no need of backend programming.
    My job is to submit and move to the next function . the output will be determined via custom profile option.
    now, for this package I am directly assigning the values like appshort name , prog shrt name , and parameter.
    there is no mention of layouts anywhere in the standard workflow package .
    its very urgent for me friend.
    Regards,
    Shashank.

  • RFBELJ10 output in XML format

    Hi,
    We have a requirement in Italy to have the document journal output created in XML format. As we all know, SAP does not have such option in this report. Is there anything that we could do to get the outputs in either XML or PDF formats and save the files locally or on the application server so that we could submit it to Italian Government?
    Thank you,
    Subash Krishna

    Hi,
    above is not fiscal requirement.
    If it is fiscal requirement then please provide me a legal documentaion web link.
    Reg
    Madhu M

  • Smartforms output in XML format

    Hi everyone,
    I am very new for smartforms and my requirement to convrt given smartform in XML format, I am going through
    Form Attributes -> output options -> output format -> XSF output , then I am giving proper value in output mode & in Output Device but not getting proper output, can You please  tell me what i have to do (in Detail ) ?
    Thanks & Regards,
    Vimarsh B.

    Hi Abhinay
    I have billing order invoice, client is getting its output in standard format but now he needs the output of that form has to come in XML format, if we are using standard output format in form attributes, its showing output but when  we are chenging its option we are not getting any output, only one spool create, and we are not able to understand what exactly output will come, it will come same like standard format or only spool will create and if only spool create then how we can send it to our client. please solve this issue, thanks for ur support.
    Thanks & Regards,
    Vimarsh B.

  • How to parse an PL/SQL type to XML format in ORACLE8

    I've got a PL/SQL type ( table/records/...) and I want to set it to XML format :
    I've got
    TYPE return_row IS record (
    value_1 NUMBER(2),
    value_2 VARCHAR2(30));
    TYPE return_test IS TABLE OF return_row
    INDEX BY BINARY_INTEGER;
    VARCHAR2 XMLformat;
    And I want to set into XMLformat the value of return_test parsed to XML.

    I only
    need to know how to change a inputstream (instance of
    an online xml file) to a Node. If your want to create a Node, maybe you're thinking DOM (as apposed to SAX) and you should take a look at the API for:
    - DocumentBuilderFactory
    - DocumentBuilder
    and the
    Document parse(...)
    method family. They all return a Document, which is a type of Node.

  • Outputting in XML Format

    I would like to select the records from a query and output it
    in xml format. Is it possible?
    Thank you

    You need to move the cfoutput lower in the xml, or you will
    be repeating the <?xml version="1.0" encoding="utf-8"?> over
    and over for each record set it returns
    cfquery name="getlayout" datasource="#layout.dsn#">
    select * from tbllayout
    </cfquery>
    <cfsetting enablecfoutputonly="yes"
    showdebugoutput="no">
    <cfcontent type="text/xml">
    <?xml version="1.0" encoding="utf-8"?>
    <cfoutput query="getlayout" >
    <rowm>
    <category>#category#</category>
    <company>#company#</company>
    <addresse>#address#</addresse>
    <phone>#phone#</phone>
    <imagen>#image#</imagen>
    <itemdesign>#itemdesign#</itemdesign>
    <height>#height#</height>
    <width>#width#</width>
    </rowm>
    </cfoutput>

  • How to convert ALV output into XML format.

    Hi all,
    I just want to know how to convert an ALV output into a XML format, this is really urgent.
    regards,
    Ruchika saini

    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.
    Message was edited by:
            Hymavathi Oruganti

  • Group SQL data in XML Format

    Hi All,
    I have t-sql result set (Shown in image). I want to convert it into xml data format (like the code under Edit this code section).
    There can be any number of clients and any number of projects. Can some one please help me out on this.

    declare @t table
    client varchar(100),
    project varchar(100),
    amt varchar(100)
    insert @t
    values('client1','project1',100),
    ('client1','project2',200),
    ('client2','project1',150),
    ('client2','project2',250),
    ('client3','project1',300),
    ('client3','project2',400)
    SELECT client as [li],
    (SELECT
    project AS [li],
    amt AS [li/u1/li]
    FROM @t
    WHERE client = t.client
    FOR XML PATH('ul'),TYPE)as [li/*]
    FROM
    SELECT DISTINCT client
    FROM @t)t
    FOR XML PATH('ul')
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Very Important (Query to display the output in required format)

    CREATE TABLE TEMP(X VARCHAR2(10),Y VARCHAR2(100));
    INSERT INTO TEMP('RIDER1','2001-12;2002-32;2003-42');
    INSERT INTO TEMP('RIDER2','2001-52;2003-72');
    SELECT * FROM TEMP
    Initial Out Put in 2 columns X/Y_
    X Y
    RIDER1 2001-12;2002-32;2003-42
    RIDER2 2001-52;2003-72
    Write a Query to display the above data in the format below in 3 columns A/B/C*
    A B C
    Rider1 2001 12
    Rider1 2002 32
    Rider1 2003 42
    Rider2 2001 52
    Rider2 2003 72

    So your old version doesn't support Regular expression. It will be very easy and efficient if you could use regular expression.
    SQL> SELECT x,TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 1)) col2,
      2           TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 2)) col3
      3   FROM (
      4     SELECT DISTINCT x,regexp_substr (y, '[^;]+', 1, level) col2 
      5     FROM temp 
      6     CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (y, '[^;]+'))  + 1
      7     ORDER BY 1,2
      8        );
    X          COL2
    COL3
    RIDER1     2001
    12
    RIDER1     2002
    32
    RIDER1     2003
    42
    X          COL2
    COL3
    RIDER2     2001
    52
    RIDER2     2003
    72But for your version you can use something like
    SQL> /* By curtesy Frank Kulash */
    SQL> SELECT x,SUBSTR(the_value,1,INSTR(the_value,'-',1)-1) col2,
      2           SUBSTR(the_value,INSTR(the_value,'-',1)+1)col3
      3  FROM (
      4        SELECT DISTINCT x,SUBSTR(y,
      5                            DECODE(level,
      6                                   1,
      7                                   1,
      8                                   INSTR(y, ';', 1, level - 1) + 1),
      9                            DECODE(INSTR(y, ';', 1, level),
    10                                   0,
    11                                   length(y),
    12                                   instr(y, ';', 1, level) -
    13                                   DECODE(level,
    14                                          1,
    15                                          0,
    16                                          INSTR(y, ';', 1, level - 1)) - 1)) the_value
    17                FROM temp
    18              CONNECT BY level <=
    19                         LENGTH(y) - LENGTH(REPLACE(y, ';')) + 1
    20          )
    21  ORDER BY 1,2,3                     
    22       ;
    X          COL2
    COL3
    RIDER1     2001
    12
    RIDER1     2002
    32
    RIDER1     2003
    42
    X          COL2
    COL3
    RIDER2     2001
    52
    RIDER2     2003
    72
    SQL>

Maybe you are looking for