How to convert CLOB to varchar2 whose length is more than 4000

Hi ,
I have to retrive the CLOB data into varchar2 and spilt those comma seperated values into rows
but i am getting following error
" ORA-06502: PL/SQL: numeric or value error: character string buffer too small "
the proc i used is like following :
: create table test_clob (grp_id CLOB, id number)
Create or replace proc test_clob(p_id number )
Is
V_clob CLOB;
V_str varchar2(4000);
V_main varchar2(30000);
TYPE t_clob IS REF CURSOR;
cur_clob t_clob;
Begin
Select grp_id
Into v_str
From test_clob
Where id= p_id;
---converting column data in rows as I have to return the cursor as output
V_main:= ' select grp_id from ( WITH t AS
(SELECT REGEXP_SUBSTR(''' || v_str ||
''', ''[^,]+'', 1, LEVEL) txt
FROM DUAL
CONNECT BY LEVEL <=
LENGTH(''' || v_str ||
LENGTH(REPLACE(''' || v_str ||
''', '','')) + 1)
SELECT REGEXP_SUBSTR(trim(txt), ''[^\,]+'', 1, 1) grp_id
FROM t )';
open cur_clob for ' select rtrim(xmlagg(xmlelement(e, grp_id || '','')).extract (''//text()'').getclobval (),'','') grp_id
from ( '|| v_main||' ) ';
loop
fetch cur_clob
into V_clob;
exit when cur_clob %notfound;
end loop;
insert into test_clob
values (p_id, v_clob);
commit;
End;
Please help its very urgent

957624 wrote:
Hi ,
I have to retrive the CLOB data into varchar2 and spilt those comma seperated values into rows
but i am getting following error
" ORA-06502: PL/SQL: numeric or value error: character string buffer too small "
the proc i used is like following :
: create table test_clob (grp_id CLOB, id number)
Create or replace proc test_clob(p_id number )
Is
V_clob CLOB;
V_str varchar2(4000);
V_main varchar2(30000);
TYPE t_clob IS REF CURSOR;
cur_clob t_clob;
Begin
Select grp_id
Into v_str
From test_clob
Where id= p_id;
---converting column data in rows as I have to return the cursor as output
V_main:= ' select grp_id from ( WITH t AS
(SELECT REGEXP_SUBSTR(''' || v_str ||
''', ''[^,]+'', 1, LEVEL) txt
FROM DUAL
CONNECT BY LEVEL <=
LENGTH(''' || v_str ||
LENGTH(REPLACE(''' || v_str ||
''', '','')) + 1)
SELECT REGEXP_SUBSTR(trim(txt), ''[^\,]+'', 1, 1) grp_id
FROM t )';
open cur_clob for ' select rtrim(xmlagg(xmlelement(e, grp_id || '','')).extract (''//text()'').getclobval (),'','') grp_id
from ( '|| v_main||' ) ';
loop
fetch cur_clob
into V_clob;
exit when cur_clob %notfound;
end loop;
insert into test_clob
values (p_id, v_clob);
commit;
End;
Please help its very urgentNo, nothing is urgent here and it is very rude to suggest it is, as well as it being a breach of the terms of use for the forums. Urgent issues relate to commercially live systems, and for those you need to raise a support request with Oracle Support. The forums are manned by volunteers with their own jobs to do, so suggesting they drop everything to help you urgently is very rude. Also, other people asking questions would like answers to theirs as soon as possible too, so suggesting your question is more urgent than theirs is also rude to those people. You will find that suggesting your question is urgent will actually prevent people from helping you on the forums as many people will simply choose to ignore you for your rudeness (either that or they'll be rude back)
Please read {message:id=9360002} to learn how to ask a question properly.
Now, in answer to your question...
What is it you are really trying to do?
If you have comma seperated data, why it is being stored like that in a CLOB? That seems like bad design for storing data.
If the data is coming from a file, then you could consider using External Tables (or SQL*Loader) to load the comma seperated data in a structured way.
If you really have data in a clob in comma seperated format, what are you wanting to do with it exactly i.e. what determines where the data should be split?
Your code isn't clear, but it looks like, on the one hand you are splitting comma seperated data out of a string, and on the other hand you're turning it into XML to get a clob of data back.
Please be clear by providing some example data and expected output, along with your database version as explained in the FAQ post I linked to above.

Similar Messages

  • How to convert clob to varchar2 in an update trigger

    Hi,
    I need to convert a field (clob) to varchar2 in a update trigger, how can I do that?
    regards.

    The maximum amount of data you can store in CLOB column is 4GB.
    You have table TABLE1 having col1 CLOB datatype.You have one more table
    Table_audit_1 without having CLOB datatype column and want to move CLOB
    data into VARCHAR2 column which has maximum length of 4000 and want to
    audit col1 CLOB into VARCHAR2.It seems to me you dont care about the data
    beyond 4000 bytes.
    In 9i SUBSTR, INSTR can be performed without reference to the DBMS_LOB
    package.
    SQL> DROP TABLE mytable
      2  /
    Table dropped.
    SQL> DROP TABLE mytable1
      2  /
    Table dropped.
    SQL> CREATE TABLE mytable
      2  (a   NUMBER,b   CLOB)
      3  /
    Table created.
    SQL> CREATE TABLE mytable1
      2  (c  NUMBER,d   VARCHAR2(4000))
      3  /
    Table created.
    SQL> DECLARE
      2      loc           CLOB;
      3  BEGIN
      4      FOR i IN 1..5000
      5      LOOP
      6        loc:=loc||i;
      7      END LOOP;
      8      INSERT INTO mytable  (a,b) VALUES (1,loc);
      9      INSERT INTO mytable1 (c,d) VALUES (1,SUBSTR(loc,1,4000));
    10      COMMIT;
    11  END;
    12  /
    PL/SQL procedure successfully completed.
    SQL> SET LONG 5000
    SQL> CREATE OR REPLACE TRIGGER mytrigger BEFORE UPDATE ON mytable FOR EACH ROW
      2  BEGIN
      3      UPDATE mytable1
      4         SET d=SUBSTR(:NEW.b,1,4000)
      5       WHERE c=:NEW.a;
      6  END;
      7  /
    Trigger created.
    SQL> DECLARE
      2      loc           CLOB;
      3  BEGIN
      4      FOR i IN 1..1000
      5      LOOP
      6        loc:=loc||'A '||i;
      7      END LOOP;
      8      UPDATE mytable
      9         SET b=loc
    10       WHERE a=1;
    11      COMMIT;
    12  END;
    13  /
    PL/SQL procedure successfully completed.
    SQL> SELECT LENGTH(b) FROM mytable
      2  /
    LENGTH(B)
          4893
    SQL> SELECT LENGTH(d) FROM mytable1
      2  /
    LENGTH(D)
          4000
    SQL> Khurram

  • How to convert CLOB to BLOB with SQL Developer migration wizard?

    Hi,
    According to our requirement, we need to only migrate data from SQL Server 2008 to Oracle 11. I use the SQL Developer 3.0.04 migration wizard to do it.
    I do migration from SQL Server (database name: SCDS41P2) to Oracle (User name: HCDS41P2).
    My migration steps are as below: (I need to modify the target schema, so I add the steps 2) and step 3) )
    1) Do migration by SQL Developer migration wizard;
    2) Remove the Converted Database Objects node from migration project;
    3) Re-do convert by SQL Developer migration wizard (contains changing the target schema);
    When do step 1), the DBO_SCDS41P2 user is created automatically. CLOBTOBLOB_SQLDEVELOPER procedure is also created in this user.
    I continued to run step 2) and step 3) with online mode. And find the table data which contains BLOB column can be moved into the target table. But from the Logging Page, I can't see the other detailed error info, so that I can't check which tables don't move data successfully.
    Could you please tell me where the detail log file (e.g. contains every table's migration status) is if I use the online mode?
    Additional, If I use offline mode to do step 3), I found the CLOB data can't be converted into BLOB automatically. Because in the load script (that is oracle_ctl.bat), only copy the source data to the CLOB column. After copy, it don't deal with the converting from CLOB to BLOB.
    So could you please tell me how to convert CLOB to BLOB with offline mode?
    Thanks so much.

    Hi,
    For your first question about logging - after the migration there will be an entry in the right hand panel for the migration project. If you open this there are various fields that give information about the status of each part of the migration. Does this give you the information you need ?
    For the second problem about offline moving blob data have a look at the SQL*Developer documentation -
    Oracle® SQL Developer User’s Guide Release 3.0
    in the section -
    2.2.8.1.4 Populating the Destination Database Using the Data Files
    which describes the problem and how to get round it.
    Regards,
    Mike
    Edited by: mkirtley on Aug 12, 2011 10:49 AM

  • How to convert CLOB data (now it is in html format) to Normal text format

    Hi,
    Can anybody let me know the solution for how to convert CLOB data into normal Text.In my case the table column having CLOB datatype and the data is in html format.when i run the report the column is displaying html tags .Now i need to convert that html tags into normal text.
    Pl. let me know if any one know the solution.
    Regards,
    Thulasi.K

    LONG has been depricated since 8i so I don't believe there is a general solution to go backwards short of reloading the data.
    Justin

  • How to perform Text length more than 4000 bytes

    I want to read each row from txt file
    and used utl_file pacage to concat contents into a variable,
    the variable datatype is varchar2(4000), so text length can't more than 4000 bytes,
    but I wish get full text from txt file, How can I do?

    Thans! Detlev.
    I have a code :
    PROCEDURE read_file( path in varchar2, filename in varchar2, msg in out varchar2) AS
    data_line varchar2(4000);
    ifile utl_file.file_type;
    BEGIN
    ifile := utl_file.fopen(path,filename,'R');
    LOOP
    utl_file.get_line( ifile, data_line);
    msg := msg | | rtrim(data_line);
    END LOOP;
    utl_file.fclose(ifile);
    EXCEPTION
    WHEN no_data_found THEN
    utl_file.fclose(ifile);
    END;
    My question is
    1. The msg length can't more than 4000
    2. I use utl_raw.cast_to_raw function, that can't cast varchar2 to raw if varchar2 length more than 2048
    3. If I want to change the data type varchar2 to raw,
    the utl_raw.concat function can't use Loop ....end loop clause,
    So that only use utl_raw.concat(ra1, ra2,ra3,ra4,ra5, ... ra12)
    I want to concat all line to a raw datatype from text file , How can I do?

  • How can I make Function return varchar2 more than 4000

    I have a function
    FUNCTION testing (v_pk_application in number, v_inccharges in char)
    return varchar2(30000)
    --return number
    is
    v_net_sum varchar2(30000);
    v_net_sum2 varchar2(30000);
    v_datarow varchar2(3000);
    v_datarow2 varchar2(3000);
    begin
    return v_net_sum;
    end;
    I want to return varchar2 more than 4000, how can I do that.
    Thanks

    user10659388 wrote:
    I want to return varchar2 more than 4000, how can I do that.A function can return a string up to the maximum allowed for varchar2.
    Varchar2 can be up to 32767 characters...
    SQL> create or replace function ret_str return varchar2 is
      2    v_str varchar2(32767);
      3  begin
      4    v_str := lpad('*',32767,'*');
      5    return v_str;
      6  end;
      7  /
    Function created.
    SQL> declare
      2    v_retstr varchar2(32767);
      3  begin
      4    v_retstr := ret_str();
      5  end;
      6  /
    PL/SQL procedure successfully completed.However, SQL only supports varchar2 up to 4000 characters so the same function will cause SQL to error, even though the function is perfectly valid.
    SQL> select ret_str() from dual;
    select ret_str() from dual
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "SCOTT.RET_STR", line 5
    SQL>So, if you intend to use the function only in PL/SQL then you can use varchar2 up to 32767 characters, but if you intend to use it in SQL then you will be limited to returning 4000 characters. Alternatively you can return a CLOB which SQL supports but they are a little more tricky to work with than varchar2...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function ret_str return clob is
      2    v_str clob;
      3  begin
      4    v_str := lpad('*',32767,'*');
      5    return v_str;
      6* end;
    SQL> /
    Function created.
    SQL> select ret_str() from dual;
    RET_STR()
    SQL>

  • Cant  we create a custom PA infotype whose size is more than 1000 chars?

    can we create a custom PA infotype whose size is more than 1000 characters
    i have tried this way i have given 4 fields in PM01 transaction with the data element 255 so the total size is 1020 it is throwing an error. pls help......

    Hi,
    as described in the following documentaion the length of the data could be 1500 bytes.
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/4f/d526be575e11d189270000e8322f96/content.htm
    Regards
    Bernd

  • How can I see if my program is for more than one user? We think we have bought in design for more users, but can not find out how to get in for more than one?

    How can I see if my program is for more than one user? We think we have bought in design for more users, but can not find out how to get in for more than one?

    If you bought a CC for team, you can log in at http://adobe.com and insert the e-mail that you gave at the moment at the purchase and than you can manage and see you product/plan/team.
    If I was not clear you can use the following link to help you solving your issue:
    Creative Cloud Help | Manage your Creative Cloud for teams membership
    If your not clear about this situation, contact with an agent of Adobe, by chat or phone. Use the following link to see the type of support you have on this matter:
    http://adobe.com/getsupport
    I think this will help you.
    Regards

  • How to multiple/ parellal sets of books to generate more than one financial statement based on different (or the same) accounting principles.

    How to multiple/ parallel sets of books to generate more than one financial statement based on different (or the same) accounting principles.
    My Client needs Parallel Ledger in SAP B1 similar like SAP ECC. Is this functionality available ?

    Dear Mr. Nagrajan,
    Thank you for your response. I have already gone through documents but not able to understand. Is there any setup for this ? or its just work around i.e. using template and special field in JV i.e. Ref. 1 /2
    My doubts :
    I understand that Chart of Account structure is one and common for IFRS and other accounting method. We need to create only those account separately ( 2 times with prefix like IFRS revenue account, GAAP Revenue account).
    Now at time of entry, Assume some entries / adjustment are specifically for IFRS and not for other ledger. In this case, What need to do ?
    You have mentioned about DTW approach but do we need to insert all JV's again with other ledger ?
    Someone suggested that if any entry which are specific to IFRS Ledger, We need to user Ref.1 /2 column or Transcation code column and in which we can put IFRS
    Based on this, Need to create 2 seperate template for IFRS and other ledger for all report.
    This is my understanding of Solution in SAP B1. Please help me to clarify my though process
    Please do needful.If you have done implemenation and if you can share doucment, it would be great help.
    Email :[email protected]

  • Need to insert into a table 1 of the fields (CLOB)with more than 4000 chars

    Dear Gurus,
    As far I understood, I need to write a function which get as parameter the large text and using bind variables I can return a CLOB containing more than 4000 chars. I tried all I can do and feel I want to died. Please, can I get specified help in this issue?
    I APPRICIATE YOUR HELP, MARCELO.

    *** Duplicate Post ***
    Please, Marcelo, use the forum properly. Pick a single group and post there.
    Thank you.

  • How can i play a movie in keynote from more than 600 seconds between other slides in a automatic loop

    How can i play a movie in keynote from more than 600 seconds between other slides in a automatic loop

    The maximum duration available for an automatic presentation in Keynote is 600 seconds.
    The alternatives are to export a QuickTime video, use other presentation applications, a media server player or digital signage application.

  • SMARTFORM: how to create 3 copy (each copy can print more than one page)

    SMARTFORM: how to create 3 copy (each copy can print more than one page)
    Hello everyone.
    my user want to have form that print 3 copy.
    such as 1 copy description = master,  2 copy description = copy 1 ,3 copy description = copy 2.
    so i create 3 page . I copy from page 1.
    and in each page there is main window which can have data more than 1 page.(such as have a lot of sale data ,it's take 2 page for show output .so it's take 2 page in each copy)
    please help me.
    how to set page and window in each page for print 3 copy and each page can have main window that print more than 1 page

    Hello Vinit.
    thank you very much for your help.
    could you help me more please.
    in below code
      DO NAST_ANZAL TIMES.
    l_counter = l_counter + 1.  " << pass this to FM and use for the TEXT to print
    CALL FUNCTION LF_FM_NAME
               EXPORTING
                         COUNTER = l_COUNTER   " USE this to derive the text into PRINTOUT
    enddo.
    Now i out of office .so i cannot test.
    where do i set NAST_ANZAL for 3 ?
    can i input ?
    NAST_ANZAL = 3.
      DO NAST_ANZAL TIMES.
    l_counter = l_counter + 1.  " << pass this to FM and use for the TEXT to print
    CALL FUNCTION LF_FM_NAME
               EXPORTING
                         COUNTER = l_COUNTER   " USE this to derive the text into PRINTOUT
    enddo.
    Edited by: dittaporn nanasilp on Mar 12, 2011 3:33 PM

  • How to export or delivery report for Excel for more than one sheet in OBIEE

    Hi Experts,
    How to export or delivery report for Excel for more than one sheet in OBIEE 11g? (Every time, I can only see one sheet.)
    Is it possibl to implement this requirement?
    Thanks.

    there are 2 oprions,
    One is have your tow report in a single compound layout of analysis and keep the report in dashboard and give report links.
    it will cath both your report.
    Suppose your analysis are different.
    Then you have the option of printing it to a PDF. on ritght top of Dashboard, Print - > Printable PDF.
    you ca export to PDF no to excel.
    mark if helps,
    fiaz

  • How can we know that size of dimension is more than fact table?

    how can we know that size of dimension is more than fact table?
    this was the question asked for me in interview

    Hi Reddy,
      This is common way finding the size of cube or dimensions or KF.
    Each keyfiure occupies 10 Bytes of memory
    Each Char occupies 6 Bytes of memory
    So in an Infocube the maximum number of fields are 256 out of which 233 keyfigure, 16 Dimesions and 6 special char.
    So The maximum capacity of a cube
    = 233(Key figure)10 + 16(Characteristics)6 + 6(Sp.Char)*6
    In general InfoCube size should not exceed 100 GB of data
    Hope it answer your question.
    Regards,
    Varun

  • How do i get  my i phone to show more than just the apple symbol?

    how do i get  my i phone to show more than just the apple symbol?

    Welcome to the Apple Community.
    AirPlay Mirroring requires a second-generation Apple TV or later, OS X 10.8 or better and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer). It also requires the computer to be using wi-fi.

Maybe you are looking for

  • How do i use my time capsule to back up another mac?

    How do I set up my time capsule to back up another mac computer?

  • SD Billing Listing & DO Lisitng

    Dear Expert, Any standard SAP report that could list out all the billing?  User dont want VF05 because VF05 have to generate customer code by customer code. Thanks, Kiran D.

  • De-install Reader?

    How do I de-install a reader on my Mac which is not performing and re install later.  It wont allow me to install a 'fresh' version because it says it is already installed?

  • Compiling package

    I don't know if this is the correct place to call for help - specially since I don't know if my problem falls in Tomcat domain or Java/JSP domain. I have a fairly simple structure of classes - classB creates instance of classA both are part of a pack

  • Automator services don't work after updates

    I recently installed some software updates (the last Security Update, the Java update, Software Installer Update, and at least one other that I can't recall. A couple of months ago, I had set up some Launch Application services (launched with  assign