Conversion of several lines (with 1 column) to 1 row of concatenated values

Hi experts,

We have a table with a column:

Column1
A
B
C
D

and we want to get:

Column1
A, B, C, D

Any help please?

Thank you!

Hello

This is called the aggregation of the chain and this page:
http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php
shows several ways to do so.

Which way is best for you? It depends on your version of Oracle and exactly to your needs (for example, if the items in the list should be in order or not).
If you use Oracle 11.2, then new LISTAGG built-in function is probably what you want.

Published by: Frank Kulash, April 12, 2011 13:01

Tags: Database

Similar Questions

  • SQL to convert a row with 4 columns to 4 rows with 1 column

    Sorry, I know this question has been asked hundreds of times before!

    This is my starting SQL:

    set linesize 500
    
    with tbl_data AS
     (select 'N' argument1, 'Y' argument2, NULL argument3, 'Y' argument4 from dual)
    select * from tbl_data;
    
    
    ARGUMENT1 ARGUMENT2 ARGUMENT3 ARGUMENT4
    --------- --------- --------- ---------
    N         Y                   Y        
    

    Is it possible to enter the data in this format:

                    COL_HEADING
    ARGUMENT1       N
    ARGUMENT2       Y
    ARGUMENT3       
    ARGUMENT4       Y
    

    I have read comments UNPIVOT but can't really work on the syntax to get a single line with 4 columns to appear as 4 rows with 1 column.

    Sorry - I realize that I'm probably be lazy and stupid.

    Any advice much appreciated, thank you.

    Hello

    Here's a way to do it with UNPIVOT:

    SELECT *.

    OF tbl_data

    MUST INCLUDE NULL VALUES

    (col_heading

    FOR column-name IN (argument1

    argument2

    argument3

    argument4

    )

    )

    ;

    Output:

    COLUMN COL_HEADING

    --------- -----------

    ARGUMENT1 N

    ARGUMENT2 Y

    ARGUMENT3

    ARGUMENT4 Y

  • Get several lines with the request - please help

    Hello

    I have query that gives me the output below.
    select distinct a.*,cu1.usr_key,cu1.first_nm,cu1.last_nm
    from(
          select ng.grp_key, ng.grp_nm , gt.grp_typ_nm, stts.nm as grp_sts, ng.expiry_date, ng.updt_dttm, stts.stts_key
          from new_group ng, user_group ug, group_type gt, status stts
          where ug.grp_key = ng.grp_key and ng.grp_typ_key = gt.grp_typ_key and 
          ng.stts_key = stts.stts_key and
          ug.usr_grp_rl_typ_key = 1 and 
          lower(ng.grp_nm) like 'test foe%'
          union 
          select ng.grp_key, ng.grp_nm , gt.grp_typ_nm, sts.nm as grp_sts, ng.expiry_date, ng.updt_dttm, sts.stts_key
          from new_group ng, group_type gt, status sts
          where ng.grp_typ_key = gt.grp_typ_key and ng.stts_key = sts.stts_key and 
          lower(ng.grp_nm) like 'test foe%')a, common_user cu1, user_group ug1
    where cu1.stts_key = a.stts_key and cu1.usr_key = ug1.usr_key and ug1.usr_grp_rl_typ_key = 1 and ug1.grp_key(+) = a.grp_key;
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 09.38.34 29742 Sam Saed
    18345 enemy test remove Group organization DELETED 9 February 12 09.38.34 AM 3 29643 dummyName514 dummy
    18345 enemy test remove Group organization DELETED February 9, 12 09.38.34 AM 3 28917 TestMObileUser Gujral
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 27284 Rocky jegou 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28920 Bhavani Gujral 09.38.34
    18345 enemy test remove Group organization DELETED 9 February 12 09.38.34 AM 3 29645 dummyFName516 dummy
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 27316 Karthik Gilani 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28147 Bowl David Mathews 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 09.38.34 29731 Sam Saed
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28919 Madhu mango 09.38.34

    For a group 18345, there are 10 users and this is the reason why I get a multiple user records.

    I can't avoid these last three columns, because I have to show these values in the application.

    In my opinion, the UNION is at the origin of the problem. Can I replace the UNION here? Please share your ideas on this.

    Thank you
    Rambeau

    Published by: ouali on February 9, 2012 22:35

    Hello

    because I have to show these values in the application.

    What is your problem then? If you simply issue a SELECT statement to application code or send the data back to REF CURSOR, it will be quite OK to have several lines. That's what the SELECT statements are for: to return sets of results with several lines.
    So, could not explain your problem more in detail please? If you get an error somewhere, provide the code causing the error and the error message (it is probably ORA-001422 exact extraction returns several lines somewhere in PL: / SQL, isn't it? then post here).

    In my opinion, the UNION is at the origin of the problem. Can I replace the UNION here? Please share your ideas on this.

    Us don't know not the answer to this question, because no one here knows your needs (what you need).

  • Failed to insert a new line with a column generated sequence id

    Hello

    I'm trying to insert a new row in a table containing a column of sequence according to db, used as the primary key.

    Here is the code for the custom method of the corresponding AM I use to insert the new line:

    Line row2 = getCaAppointments1 () .createRow ();
    row2.SetAttribute ("Member ID", Member ID);
    row2.SetAttribute ("Status", "Planned");
    row2.SetAttribute ("CreatedBy", coachId);
    row2.SetAttribute ("CreationDate", date);
    AppointmentId will be generated by the sequence
    DBSequence newId = row2.getAttribute("AppointmentId") (DBSequence);
    SequenceImpl s = new SequenceImpl ("XX_CA_APPOINTMENT_ID", getDBTransaction());
    Long next = newId.getSequenceNumber () .longValue ();
    System.out.println ("Got sequence as id:" + newId);
    row2.SetAttribute ("AppointmentId", newId);
    row2.SetAttribute ("CoachId", coachId);
    row2.SetAttribute ("Type", "0");
    row2.SetAttribute ("AppointmentNumber", 0);
    row2.SetAttribute ("PlannedDate", Department of justice);
    getCaAppointments1 (.insertRow (row2));

    I put the attribute EO 'AppointmentId' to use a DBSequence. I tried different combinations to get the sequence Id and insert a line. Nothing worked well and I'm unable to insert a new line.

    If I avoid using the attribute 'AppointmentId' and that you try to insert a row, it will fail with the error below:

    ORA-01400: cannot insert NULL into ('APPS'. "" "" XX_CA_APPOINTMENTS '. "" APPOINTMENT_ID") ORA-06512: at line 1

    Tried to insert the new row using BCTester but I am struck by the same error it (I was unable to change the value of the "AppointmentId" column when inserting the line because this column is read-only and it showed as - 2 value).

    I guess, since the attribute of column/is already marked to use a DBSequence, the value should be assigned by default and I shouldn't hit "cannot insert the value NULL to the column.
    Did I miss something necessary to trigger the sequence to automatically generate new Id and assign it to the new line before it is created?

    Please let me know the fix.

    Thanks in advance
    Rouhaud

    Hello

    Oracle changes this behavior each version, so I hope that its still OK.
    If you have a trigger on the table that inserts the value of the id if none is preset, then mark it as DBSequence, or be it the number.

    Now for your entity, just generate the impl class and override the method create, kind of old school, I know, but it never fails.
    In the create just add the code to your sequence you had:

    SequenceImpl seqImpl = new SequenceImpl("", thisTransaction);
    Number idValue= s.getSequenceNumber();
    setAttribute("Id", idValue);
    

    -Anton

  • Insert several lines with dynamic data

    Hello
    When I do an insert into a table that has several lines of dynamic information. on
    a page, it inserts all rows that are dynamically filled. I want only what he
    to insert the lines that I choose the initials on. How can I do? Let's say I
    have 5 items that are displayed on a page and I want to insert only original
    the first 2 because the last 3 are left blank, how should I do this? I tried
    implementation of an if statement that says:

    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    Then make the insertion in the table

    < cfelse >
    < / cfif >

    I have this game were also up in a loop that says:

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"

    Here is the code for just the insertion. I also have a code here
    Update another table. I got this to work, so I just try to get the insertion
    works fine for the moment. I can not use this where the query statement:
    Where ItemID = #id # because I'm trying to insert into the table of approval, not
    the items table. The table is just updated with some other info. in
    a few other input boxes.

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"
    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    < cfquery Datasource = '#application. DataSource #">"
    Insert into accreditation (APV_ItemID,
    APV_ECID,
    Document_Type,
    Approval_Initials)

    Values (' #Evaluate ("form.) (' ItemID # help # ") #',
    ' #Evaluate ("form. ("ECID # help #") #',
    < cfif isDefined (form '. ') ("Help of # PNR_Doc_Type # ') and
    "form. "Help of # PNR_Doc_Type #" NEQ "" > "".
    ' #Evaluate ("form. ("Help of # PNR_Doc_Type # ') #',
    < cfelse >
    NULL,
    < / cfif >

    < cfif isDefined (form '. ') ("Help of # PNR_Approval_Initials # ') and
    "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".
    ' #Evaluate ("form. (Aide de # PNR_Approval_Initials #») #
    < cfelse >
    Null value
    (< / cfif >)

    < / cfquery >

    < / cfif >
    < / cfloop >

    On the page display, just a table of dynamic info. Here are the 4
    things that I have on this page that needs to be inserted to the database.

    < input type = "hidden" name = "' ECID #ItemID #" value = "#ECID #" > "
    < input type = "hidden" name = "' ItemID #ItemID #" value = "#ItemID #" > "
    < input type = "hidden" name = "" PNR_Doc_Type #ItemID # ' value = "PNR Req" > "

    < td align = "center" >
    < cfif Approval_Initials is not "" > "".
    #Approval_Initials #.
    < cfelse >

    < select name = "PNR_Approval_Initials #ItemID #" >
    < option value = "" > select initials < / option >
    < cfloop query = "ShowInitials" >
    < Cfif Engineer_Initials EQ 1 >
    < option value = "#Initials #" > #Initials # < / option >
    < / cfif >
    < / cfloop >
    < / select >

    < / cfif >
    < table >

    Can someone help me please on just the insertion in the database so that it
    will insert on the lines that I chose the initials on and not others? Thank you.

    Andy

    You almost managed, but I see that you have commented.

    (" The help of # PNR_Approval_Initials # ') AND form ["PNR_Approval_Initials # help #" ""] NEQ "" >

    Do things here

  • Updated several lines with different values

    Hello!
    I have a problem. I need to update more than 1000 lines with different values. How can I do?
    For exsample I have table:
    ID; color, date,
    1 red
    2 green
    3 white

    I need to update the date field.

    Update table
    Set date = '01.02.03'
    where id = 1

    Update table
    Set date = '01.03.03'
    where id = 2


    Maybe it's how to update multiple rows in a single request?

    Sorry for my bad English.
    Thank you!

    Hello

    You can try this

    UPDATE TABLE SET DATE = CASE
                        WHEN ID = 1 THEN TO_DATE('01-02-03','DD-MM-RR')
                        WHEN ID = 2 THEN TO_DATE('01-03-03','DD-MM-RR')
                        END
    

    see you soon

    VT

  • Assignment of sequential numbers to several lines with a common attribute

    Oracle 10i, seek to alter a query only select a total of 96 unique compoundnames and number each batchids Group 1-96.


    Entry
    Table EX

    Unique_ID, CompoundName, BatchID, quantity
    -------------------------------------------------------------------
    1, 1000 EX, EX 1000 100, 100
    2, 1000 EX, EX 101 1000, 100
    3, 1000 EX, EX 1000 102, 100
    4, EX 1001, EX 1001 100, 100
    5, EX 1001, EX 1001 101, 100
    6, EX 1001, EX 1001 102, 100
    7, EX 1001, EX 1001 103, 100
    8, EX 1001, EX 1001 104, 100
    9, EX 1001, EX 1001 105, 100
    10, EX 1002, 1002 100 EX, 100
    11, EX 1002, 1002 101 EX, 100
    12, EX 1002, 1002 102 EX, 100
    .
    .
    .
    100 +, EX 1095, EX-1095 100, 100


    -----
    Using

    Select distinct * from
    (
    Select Unique_id, CompoundName, batchid, quantity, Sum (Quantity) on sumqty (CompoundName partition)
    EX
    )
    where < 500 sumqty
    Order by 2, 3;

    Provides data collected by compoundnames and the total amount of all sharing the same name composed data (and only the results with the total amount < 500).

    I am looking for a way to recover only 96 compoundnames unique (not total the data lines) at a time and the numbering of resemble them this desired output;


    Unique_ID, CompoundName, BatchID, quantity, Sum (Quantity)?
    -------------------------------------------------------------------
    1 EX 1000, 1000, 100, 100, 300, 1 EX
    2, 1000 EX, EX 101 1000, 100, 300, 1
    3, 1000 EX, EX 1000 102, 100, 300, 1

    10, EX 1002, 1002, 100, 100, 300, 2 EX
    11, EX 1002, 1002, 101, 100, 300, 2 EX
    12, EX 1002, 1002, 102, 100, 300, 2 EX
    .
    .
    .
    100 + EX-1095, EX 96, 100, 100, 100 1095

    Thanks in advance.

    Published by: user13112928 on June 26, 2010 11:49

    Published by: user13112928 on June 26, 2010 11:50

    Published by: user13112928 on June 26, 2010 12:01

    Then place the DENSE_RANK of the outer query when you filter the data, not the inner query where you have it now.

  • How to get several lines with series C 9501 running with SoftMotion on a cRIO 9074 modules?

    Hello

    I'll have set up many of the variable axes defined by the user with two modules in series c 9501 running on a Compact RIO 9074 stepper.

    I started with the example of "9501 Stepper Drive (Getting Started)", which worked fine with a simple variable user defined axis (Test-interactive panel, SoftMotion functionality on the host).

    I need to control 2 axes and I could not find any help on adding a second axis, so I came up with the following approach. My approach was to expand the FPGA VI in a way to add features to the second variable axis defined by the user, so I did the following steps:

    1. Add a new variable axis defined by the user.

    2. Add the variables defined by the same user as the first axis had during the second axis.

    3. a copy of global variables that the first axis necessary to use independent global variables for the second axis.

    4. develop the FPGA VI while-loops with the circuits of same for axis 2 and ensure that the circuits for axis 2 use their own global variables, the right modules, their user-defined variables and change the index of the axis from 0 to 1 (don't know exactly how the axis index is defined).

    4B. I also tried to copy all the loops for each axis had their independent loops. Then adapt the global variables, modules, the variables defined by the user, index of the axis.

    The FPGA VI compiles and runs, but when I get to the Panel of interactive Test for both axes and try to enable them, it throws an error-70228 (Controller unable to confirm that the drive is enabled).

    I'm doing something wrong? Is it perhaps a simpler way to get two 9501 modules working with SoftMotion?

    I can provide my two examples of published projects (same loop loop / independent), if necessary.

    LabVIEW installation:

    LabVIEW 2014f1

    Module FPGA 2014

    In time real Module 2014

    SoftMotion 2014f1

    cRIO-drivers 2014f1

    Xilinx tools 14.7 2014

    I hope someone can help me, thanks in advance.

    I managed to make it work.

    I was missing that a Subvi in the FPGA VI engine control missed their axis index 0. I couldn't even they worked with an index of the axis until I looked into the block diagram of those.

    So what happened was that my routines on the second axis disabled immediately the first axis because of bad axis index.

    Definition of the index of 0 and 1 axis (axes 1 and 2) for each unique Subvi of motor control was what was missing.

  • Restrict lines with separate columns

    Hello

    I have all of the following documents:
    Name Dept

    John management
    Peter HR
    John Marketing
    Peter finance
    Harry operations

    Now I want to select only one record of each to John, Peter and Harry... it's name should be separate, Department it can be any one of the folders.
    Like this
    Name Dept
    Management of John (or Marketing)
    Peter HR (or Finance)
    Harry operations

    You could take the first record of a name and filter any file with the same name. Another method would be as well. I tried
    to make a request for this for some time without success.

    Thank you very much.

    keep things simple:

    SQL> WITH det AS
      2       (
      3          SELECT 'John' na_me, 'Management' dept
      4            FROM DUAL
      5          UNION ALL
      6          SELECT 'Peter', 'HR'
      7            FROM DUAL
      8          UNION ALL
      9          SELECT 'John', 'Marketing'
     10            FROM DUAL
     11          UNION ALL
     12          SELECT 'Peter', 'Finance'
     13            FROM DUAL
     14          UNION ALL
     15          SELECT 'Harry', 'Operations'
     16            FROM DUAL)
     17  SELECT   na_me, MIN(dept)
     18      FROM det
     19  GROUP BY na_me;
    
    NA_ME MIN(DEPT)
    ----- ----------
    Harry Operations
    John  Management
    Peter Finance
    
  • Replace repeating lines with white and don't show the distinct values

    Hi all

    I have a SQL query that looks like this:

    SELECT Item_id, item_details, category, group INC.
    OF my_items
    WHERE THE...

    The results are as follows:

    Item_id item_details category group

    001 keyboard PC - 1 Grp1
    001 keyboard PC - 2 Grp1
    003 monitor PC - 1 Grp 1
    003 monitor PC - 2 Grp 2


    What I really want, it's like to have repeated as a draft values and keep only the distinct values. I want the output to be like this:

    Item_id item_details category group

    001 keyboard PC - 1 Grp1
    PC-2
    003 monitor PC - 1 Grp 1
    PC - 2 Grp 2


    Is there a way we can do that? Help, please

    Here's a way using the Lag as mentioned by Tubby...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select '001' as item_id, 'keyboard' as item_details, 'PC-1' as category, 'Grp1' as grp from dual union all
      2             select '001', 'keyboard', 'PC-2', 'Grp1' from dual union all
      3             select '003', 'monitor', 'PC-1', 'Grp1' from dual union all
      4             select '003', 'monitor', 'PC-2', 'Grp2' from dual)
      5  -- end of test data
      6  select decode(item_id, lag(item_id) over (partition by item_id order by category, grp), null, item_id) as item_id
      7        ,decode(item_details, lag(item_details) over (partition by item_id order by category, grp), null, item_details) as item_details
      8        ,decode(category, lag(category) over (partition by item_id order by category, grp), null, category) as category
      9        ,decode(grp, lag(grp) over (partition by item_id order by category, grp), null, grp) as grp
     10  from t
     11* order by t.item_id, t.category, t.grp
    SQL> /
    
    ITE ITEM_DET CATE GRP
    --- -------- ---- ----
    001 keyboard PC-1 Grp1
                 PC-2
    003 monitor  PC-1 Grp1
                 PC-2 Grp2
    
    SQL>
    
  • How can I play files CSV lines with a different number of columns?

    Hi all

    I am trying to load CSV with DIAdem 2014 files, and I found there is a great tool, "use".

    However, with the CSV use tool, there are critical problem with my data files. (See photo)

    As you can see the CSV file attached, it includes a lot of lines with different columns.

    And here, use read the number of columns of 1st line (e.g.: 4 columns) and set it as the number of columns to read.

    So I can not load all of the data (e.g.: 53 columns) if first row data were lower than columns.

    Can anyone recommend any approach, please?

    Kind regards

    Young

    Admin 24/03/16 Note: files deleted by request of the user

    I just add a few lines of script and fix the related use. (I just added the code to get a direct look).

    The uri of the file will appear as a new kind of load in the dialog file tiara is intalled by double click

    Would be nice if you could provide some information, how the data was created. Maybe we can it add as official of our web page to use plugin.

    Option Explicit

    Void ReadStore (File)

    File.Formatter.Delimiters = «»
    File.Formatter.LineFeeds = \n
    File.Formatter.DecimalPoint = '. '.

    Dim startLine: startLine = file. GetNextLine()
    <>InStr (startLine, ' [Tenergy Bus Log Data] "" ") then
    call RaiseError()
    end if

    And that not File.Position = File.Size
    Dim groupName: groupName = file. GetNextStringValue (eString)
    If it isn't root. ChannelGroups.Exists (groupName) then
    root. ChannelGroups.Add (groupName)
    end if
    Dim grp: set grp = root. ChannelGroups (groupName)
    Dim i: i = 1
    do for real
    Dim val: val = file. GetNextStringValue (eR64)
    If isempty (val) then
    Exit
    end if
    < i="">
    dial the grp. Channels.Add ("Brand" & I, eR64)
    end if
    protected chObj: set chObj = grp. Channels (i)
    chObj.Values (chObj.Size + 1) = val
    i = i + 1
    loop
    Call File.SkipLine)
    Wend

    End Sub

  • Put 'do shell script' multi-line with comments

    I would like to integrate a Bash in Applescript script, as it is on several lines with comments.

    The only documentation useful, that I can find is tn2065, but as far as I can see, it does not say how.

    What is the correct syntax?

    Maybe I'm missing something, but you can just write your script bash as a text object and passing to the shell script:

    game of longBashCommand to "# some relevant comments.

    CD /somedir

    / bin/something - foobar

    # one other comment here

    / bin/Gisèle

    ' # one other comment.

    the shell script longBashCommand

    The trickiest part is perhaps the need to escape some characters such as quotation marks in the command shell.

  • Draw lines with smooth curves

    Hello

    I am doing a map for an underground system in a gaming PC, and I want something similar to a Transport for London has:

    http://www.tfl.gov.UK/assets/downloads/standard-tube-map.gif

    I am a total newbie with Adobe Illustrator, but I try it as I have heard that this is using Transport for London.

    My question is then, what would be the best way to accomplish several lines with different colors and smooth curves, like the lines in my table of reference?

    Thanks in advance,

    Martin

    Martin,

    Complete what by says Kurt, you can draw traces with segments of straight lines and then cut corners later, using the effect > styles > corners (you can object > decaying appearance in order to get real rounding).

  • Convert a line into several lines

    Hello

    I have a Calendar_1 table with 4 columns and 1 row

    CREATE TABLE Calendar_1
    (
    Sunday (1) tank,.
    Monday (1) tank,.
    Tuesday (1) tank,.
    Wednesday char (1)
    );

    INSERT INTO Calendar_1 VALUES ('A', ' B ', 'C' ' d ' ");
    COMMIT;

    I need to get my result under a single column 'DAYS' as shown below

    DAYS
    --------
    A
    B
    C
    D

    Could you please provide me with the required SQL code

    Concerning
    -Learnsequel

    Like this

    select decode(l, 1, sunday, 2, monday, 3, tuesday, 4, wednesday) days
      from calendar_1
      cross join (select level l from dual connect by level <= 4) 
    
  • Help to extract data Clob to a column in a table that has several lines in a table

    Help to extract data Clob to a column in a table that has several lines in a table

    It works for only the first line

    CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';

    Grant read, write on DIRECTORY XMLDIR to the public;

    () dbms_xslprocessor.clob2file

    beef in CLOB,

    XMLDIR IN VARCHAR2,

    "testfile2.txt" IN VARCHAR2);

    DECLARE

    buf CLOB.

    BEGIN

    SELECT H15_DOC

    IN buf

    OF H15TEST. H15_STAGE

    where rownum = 1;

    dbms_xslprocessor.clob2file (buf, 'XMLDIR', 'testfile2.txt');

    END;

    /

    -This error code

    CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';

    Grant read, write on DIRECTORY XMLDIR to the public;

    () dbms_xslprocessor.clob2file

    XData in CLOB,

    XMLDIR IN VARCHAR2,

    "testfile2.txt" IN VARCHAR2,

    CSID in NUMBER: = 0);

    DECLARE

    CURSOR xmlmycur IS SELECT H15_DOC

    OF H15TEST. H15_STAGE

    where rownum = 102140;

    l_clob CLOB.

    XData CLOB.

    BEGIN

    DBMS_LOB.CREATETEMPORARY (l_clob, true);

    DBMS_LOB.CREATETEMPORARY (xdata, true);

    OPEN xmlmycur.

    LOOP

    SEEK xmlmycur INTO xdata;

    dbms_xslprocessor.clob2file (xdata, 'XMLDIR', 'testfile2.txt');

    EXIT WHEN xmlmycur % notfound;

    END LOOP;

    CLOSE Xmlmycur;

    END;

    /

    ORA-21560: 3 argument is null, invalid or out of range

    ORA-06512: at "SYS." DBMS_LOB", line 991

    ORA-06512: at "XDB". DBMS_XSLPROCESSOR', line 324

    ORA-06512: at line 15 level

    FYI, it seems that the file being created will exceed 5 gig

    Yes, it is a known issue with DBMS_XSLPROCESSOR.clob2file with big files.

    Here is a slightly modified version of the code that I posted earlier, fixing WRITE_ERROR except:

    DECLARE

    v_file utl_file.file_type;

    -write a unique to clob

    procedure write_clob (p_content in clob) is

    v_buffer varchar2 (32767).

    V_POSITION pls_integer: = 1;

    v_amount pls_integer: = 32767;

    Start

    loop

    Start

    DBMS_LOB. Read (p_content, v_amount, v_position, v_buffer);

    exception

    When no_data_found then exit;

    end;

    UTL_FILE.put_raw (v_file, utl_raw.cast_to_raw (v_buffer), true);

    V_POSITION: = v_position + v_amount;

    end loop;

    end;

    BEGIN

    -Open the file

    v_file: = utl_file.fopen ('TEST_DIR', 'testfile2.txt', 'wb', 32767);

    -loops through the lines

    for r in)

    Select h15_doc

    of h15test.h15_stage

    )

    loop

    write_clob (r.h15_doc);

    end loop;

    UTL_FILE.fclose (v_file);

    END;

    /

Maybe you are looking for