ORA-06502 (character string buffer too small) on import application via script

Running apex 4.2.2.00.11
oracle 10.2.0.5
I'm using a script to import my development application to a few production applications.
It worked great on apex 4.1.1, but now I get an 'ORA-06502 PL/SQL numeric of value error: character string buffer too small'
In the command window, I see that the script fails after it starts on the plugins.
My question: is this a bug in 4.2.2?
I could be a incompatible plugin, but how can I found out which plugin?
My script is quite simple:
In a command window I run
sqlplus SCHEMA/PASSWORD@SPIEU10 @_IMPORT_F102.sql
The script is
declare
l_workspace_id number;
begin
    -- determine the workspace id for the workspace FM in the target system
    select workspace_id into l_workspace_id from apex_workspaces where workspace = 'BY_APEX_SHARED';
    -- set the context for the target workspace
    apex_application_install.set_workspace_id( l_workspace_id );
    -- override the original application id 102
    apex_application_install.set_application_id ( 102 );
    -- set a different application name and alias, it should be unique within an APEX instance
    apex_application_install.set_application_alias( 'MY_ALIAS' );
    apex_application_install.set_application_name( 'MY_APP_NAME' );
    -- Use fixed offset
    apex_application_install.set_offset( p_offset => 0);
    -- override the original parsing schema FM with a different value
    apex_application_install.set_schema( 'BY_SCHEMA' );
end;
-- install the original application export, now the values for the workspace
@f102.sql
exit;
Error message from command window:
...ui types
...plugins
begin
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 3
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64
bit Production
With the Partitioning, Data Mining and Real Application Testing options

ListAGG throws an ORA-01489 for varchar2 > 4000 bytes
OP has an ORA-06502 --> the IR is running into a 4k/32k limit.
quick solution: wrap USER_COMMENTS ListAGG in a substr( ...., 1, 4000)
Longer solution, use a subquery to modify the comments based on ROW_NUMBER() (ie after nth row, change it to NULL)
with
-- simulating data
t as (select task_id, sysdate - lv as date_entered
  ,round(dbms_random.value(1,24)) hours
  , '-*' || lv || '.' || task_id || '*-' as user_comments
from ( select level as task_id from dual connect by level <=10 ), (select level lv from dual connect by level < 1000)
-- modify data
modified_data as (
  select task_id, hours, date_entered
    ,case
      when row_number() over (partition by task_id order by date_entered desc) < 5
        then user_comments
      else null
     end USER_COMMENTS
    from t)
select task_id, sum(hours) total_hours,
  listagg( user_comments  ) within group (order by date_entered desc)
  || case when count(*) >= 5 then '! MORE COMMENTS !' else null end
    as user_comments
from modified_data
group by task_id;

Similar Messages

  • ORA-06502 character string buffer too small “  error

    We trying to insert a string of more then 500 character from our VB.net application (uses ODP.net), it’s giving “ORA-06502 character string buffer too small “ error.
    Kindly help us on this.
    OS version: AIX 5.1 (IBM/AIX RISC System/6000)
    Oracle Database version: 9.2.0.1.0

    Just for reference and to close the loop, I found the fix to this problem (quite by accident).
    The problem turned out to be a bug in the apex listener, which in some cases ended up doing a divide by zero, which caused the problem.
    This is listed as a known bug, and a fixed listener is available.
    Once I installed the fixed listener, problem solved!

  • ORA-06502 character string buffer too small, works in query not procedure

    The following query works prefect as a single query:
    with t as (select steroid_start_date as the_date from treatments where patientid = 1378 and visitnumber = 0)
        select max(case when instr(mon, '/') > 0 then NULL else mon end) mon,
             max(case when instr(yr, '/') > 0 then NULL else yr end) yr
      from ( select the_date, substr(the_date, nvl(last_pos,1), pos-1) mon, substr(the_date, pos+1) yr
              from ( select t.*,
                               instr(the_date, '/', 1, lvl) pos,
                            lag(instr(the_date, '/', 1, lvl))
                                over (
                                        partition by the_date
                                        order by instr(the_date, '/', 1, lvl)
                                     ) last_pos
                     from t, (
                                select 1 lvl
                                from dual
                                UNION ALL
                                select 2 lvl
                                from dual
                             ) b
                      where instr(the_date, '/', 1, lvl) > 0
          );I have a procedure contains:
    CREATE OR REPLACE PROCEDURE update_steroid_start_date(patid number, visit number)
    IS
        mon varchar2(3);
        yr varchar2(3);
    date1 varchar2(12);
    insert_date varchar2(12);
    BEGIN
        select steroid_start_date into date1 from treatments where patientid = patid and visitnumber = visit;
        with t as (select date1 the_date from dual)
        select max(case when instr(mon, '/') > 0 then NULL else mon end),
             max(case when instr(yr, '/') > 0 then NULL else yr end) into mon, yr
      from ( select the_date, substr(the_date, nvl(last_pos,1), pos-1) mon, substr(the_date, pos+1) yr
              from ( select t.*,
                               instr(the_date, '/', 1, lvl) pos,
                            lag(instr(the_date, '/', 1, lvl))
                                over (
                                        partition by the_date
                                        order by instr(the_date, '/', 1, lvl)
                                     ) last_pos
                     from t, (
                                select 1 lvl
                                from dual
                                UNION ALL
                                select 2 lvl
                                from dual
                             ) b
                      where instr(the_date, '/', 1, lvl) > 0
          );when I try to execute this procedure, I am getting ORA-06502 character string buffer too smal on the line
    with t as (select date1 the_date from dual)why is that? I am trying to break user input 1/2000, sometimes junk (1/ , /2000), and apply some logic so they will be 01/01/2000, NULL, 01/01/2000
    Edited by: OracleNoob on Feb 17, 2009 10:58 AM

    Hi,
    That error occurs when the variables that are being set are too short to hold the entire value being selected.
    Either make the variables longer, or the columns shorter.
    If you need mnore help, post
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data
    (4) Your formatted code
    (5) The full error message(s), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    Formatted tabular output is okay for (3) and essential for (4). Type &#123;code&#125; before and after the tabular text, to preserve spacing.

  • Report error:ORA-06502:character string buffer too small. urgent!!

    Hi guys,
    My APEX version is 3.0.1.00.08, my application run on my test environment, but on PROD environment, it raised the error:
    report error:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    In this page, on the left is a tree, the right side is a tabular form, when I click one tree node, it will pass the current node id to the form and the form will display the children data. When I click some tree node, it will raise the ORA-06502 error, but when click some other nodes, it is correct. I don't know why. And on my test environment, it has no this error, the test environment has same version with prod environment, only has less data in database. Could you help me???
    I searched in forum, someone says it's LOV problem, if it's LOV problem, all the nodes should have error, why click some nodes are ok?
    Thanks !
    Jessica

    I don't think it is related only to the number of rows but also to the content of the rows. So, counting only the number of rows doesn't say anything about if it is going to work or not. My question: can't you filter those entries? Making a choice between 250 entries in a tabular form isn't a simple task. Using popup-key LOV instead would also be a solution. However, if you use popup-key LOV be aware of the fact that you need two index numbers for those.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • WWV_FLOW_WORKSHEET_CONDITIONS - ORA-06502 character string buffer too small

    Hi,
    I am currently working on a application that can upload CSV files inside many tables. Since I hate reinventing the wheels, I have decided to reverse engineer APEX and APEX APIs that are used by the SQL Workshop to upload CSV files to a single table. Since this feature was tested many times by many developers around the world, I know I can trust the code. If in a future release of APEX those packages are modified, I'll have to update my abstraction layer to call my own packages instead of APEX packages. (This is not an issue for our team.)
    First Step
    Use apex_040000.wwv_flow_load_data.create_csv_collection to create an apex collection with the first 20 rows of the csv file. At this step, we can validate the format of a sample of the file without loading all rows of the csv file.
    Second Step
    Use apex_040000.wwv_flow_load_data.load_csv_data to upload all rows of the csv file inside a table.
    Third Step
    Do whatever you want with the data inside the table. (i.e.: Send the data into multiple tables...)
    Here's my problem..._
    After the first or second steps, I display the data using interactive reports. I want to highlight every cells containing "invalid" data. I use apex_040000.wwv_flow_worksheet_api.add_or_update_highlight. When I have too many invalid cells, the IR doesn't show at run time, and you can see ORA-06502: PL/SQL: numeric or value error: character string buffer too small on the page.
    I would like to know the limitations of IR using the table WWV_FLOW_WORKSHEET_CONDITIONS. Is there a way to create many highlight conditions inside a single row of WWV_FLOW_WORKSHEET_CONDITIONS ? I want to find the best approach to add hundreds of conditions.
    Thanks
    Louis-Guillaume Carrier-Bédard
    My Google+: https://profiles.google.com/lgcarrier
    My Blog: http://www.lgcarrier.com
    Twitter: http://www.twitter.com/lgcarrier
    APEX Québec: http://www.apexquebec.com
    APEXFramework: http://www.apexframework.com

    At run time, when I look at the html source code, I can see all the generated CSS rules to highlight the cells of the IR.
    ie.: *.apexir_WORKSHEET_DATA tr td.rule_5352115461902443_td {background-color:#FF0000 !important;}*

  • 'ORA-06502 character string buffer too small' when called from C# app

    I have researched this problem and checked my variable sizes over and over again. I have tested the procedure within the Oracle Express environment and it works fine; HOWEVER, when the procedure is called from my C# app it produces the ORA-06502 error.
    The stored procedure signature looks like this...
    create or replace save_new_project (p_custorgid in number,
      p_title in varchar2,
      p_AOIName in varchar2,
      p_description in varchar2,
      p_receiveddate in date,
      p_deadlinedate in date,
      p_startdate in date,
      p_createddate in date,
      p_createdby in varchar2,
      p_projectid out number,
      p_statustypedescrip out varchar2)The OracleParameter in my C# app for the last out param is defined as such...
    cmd.Parameters.Add(new OracleParameter("p_statustypedescrip", OracleDbType.Varchar2, 30, ParameterDirection.Output));As I said at the beginning of this post, the procedure works fine in the Oracle environment. So why is it not working by simply calling it from C#? I've tried changing the OracleDbType to CLOB which eliminates the error but it returns a bizarre result. It returns this string, "Oracle.DataAccess.Types.OracleClob". WTH?!!
    Since CLOB doesn't really work either I switch back to Varchar2 and specify a size of 5000 (in the database the field I am querying is defined as Varchar(30)). I still get the ORA-06502 error.
    I am clueless as to what the problem is. It should work and it does if I run a series of SQL statements in an Oracle SQL Command window. The test that works fine looks like this...
    declare
      v_projid projects.projectid%type;
      v_statustypedescrip projectstatustypes.type%type;   /* this is a varchar(30) */
    begin
      save_new_project(2, 'Some input text goes here', 'More input text', 'And more again','26-APR-2007','26-APR-2007','26-APR-2007','26-APR-2007','users name as inpujt text here',v_projid,v_statustypedescrip);
      dbms_output.put_line('v_projid = ' || v_projid);
      dbms_output.put_line('v_statustypedescrip = ' || v_statustypedescrip);
    end;But calling save_new_project from C# throws ORA-06502. It identifies line 40 of my stored procedure. This is line 40...
    p_statustypedescrip := v_statustypedescrip;

    Problem solved!!!
    I don't know why this worked but it did. I changed how I declared the output parameter in my C# app. I used to have it on one line like this...
    cmd.Parameters.Add(new OracleParameter("p_statustypedescrip", OracleDbType.Varchar2, 30, ParameterDirection.Output));but then I changed it to multiple lines like this...
    OracleParameter prm11 = new OracleParameter();
    prm11.ParameterName = "p_statustypedescrip";
    prm11.OracleDbType = OracleDbType.Varchar2;
    prm11.Size = 30;
    prm11.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(prm11);I don't know why it works this way but it does and that's all I care about.

  • Ideas for working around ORA-06502: character string buffer too small on Interactive report

    Hello,
    This is for Apex 4.2.  We are trying to create an interactive report.  The report is for something similar to a time tracking application.  We are trying to concat a comments column while summing the hours.  For example,
    select TASK_NAME, sum(HOURS), to_char(XMLAGG(XMLELEMENT(E,E.COMMENTS || ' : ')).EXTRACT('//text()').getstringval()) USER_COMMENTS from ......
    This query works fine if we are looking only at a 1 week window.  The issue we are experiencing is that when we expand the range of the query to include data from 3 months, we hit ORA-06502 in the interactive report.  If we remove this column from the Interactive report, then the report runs fine.
    Does anyone have any ideas on how we might be able to work around this?  I am guessing we are hitting the 32k limit on the report.  Ideally we would just show the last X number of comments and then have a link to view all the comments
    Any help would be appreciated
    Thanks
    Mike

    ListAGG throws an ORA-01489 for varchar2 > 4000 bytes
    OP has an ORA-06502 --> the IR is running into a 4k/32k limit.
    quick solution: wrap USER_COMMENTS ListAGG in a substr( ...., 1, 4000)
    Longer solution, use a subquery to modify the comments based on ROW_NUMBER() (ie after nth row, change it to NULL)
    with
    -- simulating data
    t as (select task_id, sysdate - lv as date_entered
      ,round(dbms_random.value(1,24)) hours
      , '-*' || lv || '.' || task_id || '*-' as user_comments
    from ( select level as task_id from dual connect by level <=10 ), (select level lv from dual connect by level < 1000)
    -- modify data
    modified_data as (
      select task_id, hours, date_entered
        ,case
          when row_number() over (partition by task_id order by date_entered desc) < 5
            then user_comments
          else null
         end USER_COMMENTS
        from t)
    select task_id, sum(hours) total_hours,
      listagg( user_comments  ) within group (order by date_entered desc)
      || case when count(*) >= 5 then '! MORE COMMENTS !' else null end
        as user_comments
    from modified_data
    group by task_id;

  • ORA – 06512: Character String Buffer Too Small.

    hi..
    when i'm call the Stored Procedure from php i'm getting this error
    ORA – 06512: Character String Buffer Too Small.
    but its working fine via pl/sql block in sqlplus
    CREATE OR REPLACE procedure sp_RecurringDetails(v_p in out pmxpackage.gen ,v_pmCount in out number, v_pmResult in out number) is
    v_Stmt varchar2(4000);
    v_stmtcount varchar2(4000);
    begin
    v_Stmt:= 'SELECT orders.ord_id, sub.smt_id, sub.smt_date,
    MEMBER.mem_fname,
         MEMBER.mem_lname,
         sub.smt_amount,
         sub.smt_qty,
    sub.smt_pv
         FROM MEMBER MEMBER,
         orders orders,
         sub_monthly_track sub
    WHERE ( (MEMBER.mem_id = orders.ord_memid)
    AND (MEMBER.mem_id = sub.smt_mem_id)
              AND ORDERS.ORD_RECURRING=2
              and member.MEM_DEL_STATUS=''N''
              and smt_status=0
    union
    (SELECT orders.ord_id, null,null,
    MEMBER.mem_fname,
         MEMBER.mem_lname,
         null,
         null,
    null
         FROM MEMBER MEMBER,
         orders orders
    where
    MEMBER.mem_id = orders.ord_memid
    and
    orders.ORD_RECURRINGID=2
    and orders.ord_status=''f'') order by ord_id     ';
              v_stmtcount:='select count(*) from ('||v_stmt||')';
    if (v_pmCount=-1) then
    dbms_output.put_line('');
              EXECUTE IMMEDIATE ' set serveroutput on';
              EXECUTE IMMEDIATE v_stmtcount INTO v_pmCount;
    end if;
    open v_p for v_stmt ;
    v_pmResult:=1;
    exception
    when others then
    null;
    end;
    when i'm gettting Count from the Stored Procedure sp returns the error... other wise its working fine in php
    pls give the solution for this issue
    Thanks,
    Message was edited by:
    venkatraman.L

    Tx for ur Response
    I didnt get any log when i excute this..... But it is woking fine in pl/sql Block .. But when i call from PHP page it Gives the Error
    Re: ORA – 06512: Character String Buffer Too Small.
    CREATE OR REPLACE procedure sp_RecurringDetails(v_p in out pmxpackage.gen ,v_pmCount in out Integer, v_pmResult in out Integer) is
    v_Stmt varchar2(4000);
    v_stmtcount varchar2(4000);
    v_ErrMsg varchar(1000);
    v_Errorcode number;
    begin
    v_ErrMsg:='Data--'||'Param1 is Cursor'||'--' ||Pmxpackage.Fun_Param(v_pmCount,'Param2 is null')||'--' ||Pmxpackage.Fun_Param(v_pmResult,'Param3 is null');
         IF v_pmCount IS NULL OR v_pmResult IS NULL THEN
         Pmxpackage.sp_pmxerrorlog(v_ErrMsg,'sp_RecurringDetails');
              v_pmResult:=0;
              dbms_output.put_line('nulld is ');
              RETURN ;
         END IF;
    v_Stmt:= 'SELECT orders.ord_id, sub.smt_id, sub.smt_date,
    MEMBER.mem_fname,
         MEMBER.mem_lname,
         sub.smt_amount,
         sub.smt_qty,
    sub.smt_pv
         FROM MEMBER MEMBER,
         orders orders,
         sub_monthly_track sub
    WHERE ( (MEMBER.mem_id = orders.ord_memid)
    AND (MEMBER.mem_id = sub.smt_mem_id)
              AND ORDERS.ORD_RECURRING=2
              and member.MEM_DEL_STATUS=''N''
              and smt_status=0
    union
    (SELECT orders.ord_id, null,null,
    MEMBER.mem_fname,
         MEMBER.mem_lname,
         null,
         null,
    null
         FROM MEMBER MEMBER,
         orders orders
    where
    MEMBER.mem_id = orders.ord_memid
    and
    orders.ORD_RECURRINGID=2
    and orders.ord_status=''f'') order by ord_id     ';
              v_stmtcount:='select count(*) from ('||v_stmt||')';
    if (v_pmCount=-1) then
    dbms_output.put_line('');
              EXECUTE IMMEDIATE ' set serveroutput on';
              EXECUTE IMMEDIATE v_stmtcount INTO v_pmCount;
    end if;
    open v_p for v_stmt ;
    v_pmResult:=1;
    EXCEPTION
         WHEN OTHERS THEN
              v_pmResult:=0;
              v_Errorcode:=SQLCODE;
              Pmxpackage.Sp_Pmxerrorlog(v_Errorcode,' sp_RecurringDetails',v_ErrMsg);
    end;

  • "Character string buffer too small" in translated application

    Recently upgraded to Apex 3.1
    After translating an aplications to arabic something strange happened!
    ALL the report regions are showing error:
    ORA-06502: PL/SQL: خطأ رقمي أو قيمة: character string buffer too small
    I have not experienced this in 3.01 and i have not shanged the tables.
    Whenever i switch back to english everinthing is ok.
    Has anyone seen this behaviour? Workarounds?

    I could not find any relevant messages in Apache error log.
    This is output of debug:
    source of the report region "test" is: select 1 from dual
    0.00:
    0.00: S H O W: application="115" page="998" workspace="" request="" session="4006037156338848"
    0.00: alter session set nls_language="ARABIC"
    0.00: alter session set nls_territory="SAUDI ARABIA"
    0.00: NLS: CSV charset=AR8MSWIN1256
    0.00: ...NLS: Set Decimal separator="."
    0.00: ...NLS: Set NLS Group separator=","
    0.00: ...NLS: Set date format="DD/MM/RR"
    0.00: ...Setting session time_zone to +03:00
    0.00: NLS: Language=ar-sa
    0.00: Application 115, Authentication: CUSTOM2, Page Template: 1118203615491656
    0.01: ...Session ID 4006037156338848 can be used
    0.01: ...Application session: 4006037156338848, user=ADMIN
    0.01: ...Determine if user "ADMIN" workspace "941719318732142" can develop application "115" in workspace "941719318732142"
    0.01: Session: Fetch session header information
    0.01: ...Metadata: Fetch page attributes for application 115, page 998
    0.01: Fetch session state from database
    0.01: Branch point: BEFORE_HEADER
    0.01: Fetch application meta data
    0.01: Computation point: BEFORE_HEADER
    0.01: Processing point: BEFORE_HEADER
    0.01: Show page template header
    0.03: Computation point: AFTER_HEADER
    0.03: Processing point: AFTER_HEADER
    Logout ADMIN Change Password Application CentralAdministartion
    0.03: Region: Agency Label
    0.03: Computation point: BEFORE_BOX_BODY
    0.03: Processing point: BEFORE_BOX_BODY
    0.03: Region: test
    testEdit      
    report error:
    ORA-06502: PL/SQL: خطأ رقمي أو قيمة: character string buffer too small
    0.03: Computation point: AFTER_BOX_BODY
    0.03: Processing point: AFTER_BOX_BODY

  • ORA-6502 Character String buffer too small

    Stored procedure call from C#. Ref cursors are no problem but trying to return Varchar2 is a bit of a puzzle. Just the simple code fragment below blows with ORA-6502.
    PROCEDURE getjdt2 (X OUT VARCHAR2) IS
    BEGIN
    X := 'TEST RETURN VARCHAR2';
    END;
    OracleCommand cmd = new OracleCommand ("GETJDT2", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("param1",OracleDbType.Varchar2);
    cmd.Parameters[0].Direction = ParameterDirection.Output;
    OracleDataReader reader;
    reader = cmd.ExecuteReader();
    reader.Read();
    Console.WriteLine ("Val: {0}", reader.GetString(0));

    Never mind. A bit more research and I figured it out.

  • "ORA-19011: Character string buffer too small" doing select xmlelement???

    Apparently there is a 4K limit on the amount of XML that can be produced doing a select with SQL/XML syntax, or so it appears. That is pretty disappointing. It makes this feature uselful only for demos. 256K would be a much more realistic limit for real-world applications.

    Is there any work around for this when I was using XPath I was to able use xmlsequence and come around this. But when I am using xquery execution seems to be slow, I do not want to xmlsequence and further reduce the performance.

  • ORA-19011: Character string buffer too small

    my query
    select to_clob(xmldata) from ei_output where id=1my java code...
           //load jdbc driver
                Class.forName("oracle.jdbc.driver.OracleDriver");
                // create connection
                c=DriverManager.getConnection(UI.jTxtConStr.getText(),UI.jTxtUsr.getText(),UI.jTxtPsw.getText());
                //create statement
                Statement stmt=c.createStatement();
                ResultSet rs=stmt.executeQuery(UI.jTxtAreaSQL.getText());//resulset pe baza a ceea ce e in TextArea din UI
                //get the result
                while(rs.next()){
                    is=rs.getClob(1).getAsciiStream();
                }I need the ascii stream in order to do a transform provided by apache xalan...
    what can I do about it? how can I get the ascii stream of the xmldata(xmltype)?

    Maybe a possibility would be to let the query return an XMLType instead of a CLOB or VARCHAR2 and then you can do the transformation on the server in Java instead of on the database. We tried something similar for a PL/SQL procedure:
    public Document getXML() {
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    java.sql.Connection connecton =
    DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL",
    "scott", "tiger");
    oracle.jdbc.OracleCallableStatement statement =
    (oracle.jdbc.OracleCallableStatement)connecton.prepareCall("BEGIN \"WEBSERVICE\".TEST_XML(:1 ); END;");
    statement.registerOutParameter(1, OracleTypes.OPAQUE,
    "SYS.XMLTYPE");
    statement.executeUpdate();
    //Object out = statement.getObject(1);
    XMLType xml = XMLType.createXML(statement.getOPAQUE(1));
    statement.close();
    System.out.println("out: " + xml);
    return xml.getDOM();
    } catch (Exception e) {
    e.printStackTrace();
    return null;
    The WEBSERVICE.TEST_XML procedure returns data as an XMLType object.
    Regards,
    Ronald

  • Character string buffer too small

    ORA-19011: Character string buffer too small
    My query is regarding the above error. I have a requirement to concatenate two XMLType columns in the result set and am running into the above issue. Can you please let me know how I can workaround the above problem.
    Thanks,
    YM

    Error:     ORA-19011 (ORA-19011)
    Text:     Character string buffer too small
    Cause:     The string result asked for is too big to return back
    Action:     Get the result as a lob instead

  • Listener Error - character string buffer too small (ORA-06502)

    I am running into a very strange problem with the APEX listener on seemingly random pages. I can hit every page in my application just fine, but as soon as I hit this specific one, Glassfish throws an HTTP 500 error. If I click Debug, the page seems to load fine with no indications of trouble, but as soon as I turn debug back off, it goes back to the HTTP 500 error. I don't see anything special about the page that makes this happen. It is pretty simple and has 4 regions. I have noticed that if I set any 1 of the 4 regions to "Never display", the page loads fine. It's like having all 4 of them enabled at once are causing some overload, even though it's actually a smaller amount of data than most of my other pages.
    **Update: I just discovered this only happens if I'm logged into the workspace first and then try to run the page! If I log out of APEX and then hit the application as a normal user, page loads error-free. This is still an annoying problem, but at least it seems I have a decent workaround since regular users never see it.
    After a couple days, I noticed the exact same problem on a second APEX application I'm using. Again, it is on some random page whereas all the other pages work fine.
    Both applications and pages in question worked without issue in APEX 3.x. I am trying to get an APEX application up and running on the latest version.
    I have tried both Glassfish server and simply downloading the latest listener (version 1.1.1) and running it in standalone mode. I get the problem both ways, which is why it seems it's a listener issue.
    I have seen a few other threads of people having this problem, but I never did find anyone with a solution, and most of the posts stopped back in December.
    Some details on my environment:
    Database version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    APEX version: 4.0.2
    Webserver: Glassfish 3.1
    Here is the log entry from Glassfish when the HTTP 500 error displays as I try to load one of the bugged pages.
    [#|2011-05-10T21:14:22.967-0500|INFO|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=111;_ThreadName=Thread-1;|MaxConnectionReuseCount=50000|#]
    [#|2011-05-10T21:14:46.431-0500|SEVERE|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=112;_ThreadName=Thread-1;|
    ***********ERROR***********
    init: # headers=46
    declare nm owa.vc_arr := ?;
    vl owa.vc_arr := ?;
    begin
    owa.init_cgi_env( ?, nm, vl );
    htp.init; htp.HTBUF_LEN := 63;
    ? := sys_context('USERENV','SID');
    end;
    SID:1242
    CALL:
    begin
    f(p=>?);
    commit;
    end;
    BINDS
    p:100:2:220529248574492::NOPAGE CALL:
    declare
    nlns number := 999999;
    l_clob CLOB;
    lines htp.htbuf_arr;
    l_buff varchar2(32767);
    l_clob_init boolean:= false;
    l_file varchar2(5);
    l_doc_info varchar2(1000);
    begin
    OWA.GET_PAGE(lines, nlns);
    if (nlns > 1) then
    for i in 1..nlns loop
    if ( length(lines(i)) > 0 ) then
    if ( ( lengthb(l_buff) + lengthb(lines(i))) > 32767) then
    if (NOT l_clob_init) then
    dbms_lob.createtemporary(l_clob, TRUE);
    dbms_lob.open(l_clob, dbms_lob.lob_readwrite);
    l_clob_init:=true;
    end if;
    dbms_lob.writeappend(l_clob,length(l_buff),l_buff);
    l_buff := lines(i);
    else
    l_buff := l_buff || lines(i);
    end if;
    end if;
    end loop;
    end if;
    if (l_clob_init) then
    dbms_lob.writeappend(l_clob,length(l_buff),l_buff);
    l_buff := '';
    end if;
    ? := l_clob;
    ? := l_buff;
    if (wpg_docload.is_file_download) then l_file:='TRUE'; wpg_docload.get_download_file(l_doc_info); else l_file := 'FALSE'; end if; ? := l_file;
    ? := l_doc_info;
    end;
    get_page FAILED:ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 33
    Edited by: BrianB on May 11, 2011 7:50 AM
    Edited by: BrianB on May 11, 2011 8:01 AM

    Brian,
    this post is going to get a bit longer, so the summary comes first.
    h6. Summary
    1. I could reproduce the problem on my system using the APEX Listener in standalone mode.
    2. I don't think the problem is content-related in the sense that you have any issue in your page or database contents.
    3. I have a workaround for your problem.
    h6. Error message
    Having that error in my environment made me start to think. I not only disabled some item and got it work, but I could also add something to achieve this effect.
    So I came to think, this really is somewhere deep down. The error message doesn't seem very helpful on first sight, but when starting to follow on what's happening there, things get clearer:
    APEX generates pages dynamically, replacing substitution strings and other tokens to get the actual page definition. This has to be read by a requesting client. The use of VARCHAR2 as buffer introduces a limit of 32767 bytes, after which the contents is handled as CLOB instead.
    h6. Analysis
    Obviously, there are cases where the "estimation" fails. Of course, this is may only be relevant in rare cases, because:
    1. If a page would exceed the maximum without some charset interpretation problem, the buffer would be switched to clob.
    2. If a page stays small enough to stay below 32767 even with some characters that are acutally larger then expected, the buffer isn't busted.
    To find out, if your could be one of these rare cases, I investigated the HTTP headers, focussing on X-DB-Content-length and made an odd observation.
    Test case 1: "Go" button disabled, so the page runs fine with APEX Listener
    1. It has *31968 bytes* when coming from APEX Listener with a Go button disabled.
    2. It has *31938 bytes* according to the header set by EPG - for exactly the same page.
    That makes a difference of 30 bytes for what is expected to be the same contents.
    Test case 2: The button is enabled again
    1. This causes the page load to crash in APEX Listener.
    2. EPG transports *32341 bytes* according to that header.
    So we are pretty close to the hard limit for the VARCHAR2 buffer.
    For some reason, APEX Listener seems to cause a false calculation of the actual page size. Whether this is due to some charset problem or due to some other problem with response handling, I don't know. The 30 bytes difference may result from the odd header "X-ORACLE-IGNORE" with value "IGNORE, IGNORE, IGNORE, IGNORE" sent by the APEX Listener. This value has exactly 30 bytes in length, but this could be coincidence, as there are more differences in headers. If I add the size of all headers, we are even closer to the buffer limit and probably exceed it when some items need more bytes than expected.
    This could even be as simple as a line break, as your page has about 424 lines when I disabled the button... Adding 1 byte per line to the 32341 bytes of the EPG, I get 32765 bytes. Now add that button (403 bytes difference on EPG) and you exceeed the limit. Reduce that value by the line count again and you are still below.
    Could be coincidence as well, but makes me wonder.
    h6. Workaround
    To make sure that we were actually hitting that limit, I now introduce my suggestion for a workaround.
    Test case 3: Add a hidden item
    1. APEX Listener loads the page, stating the size to be *32876 bytes*
    2. EPG sees 30 bytes less and transmits the header with *32846 bytes*
    h6. Conclusion
    I can't give you a real solution for that problem, nor do I have a definitive answer on what is the root cause for it. It seems, only one of the developers may find it. But I can offer you a workaround, which is to just add some hidden item to your page so it exceeds the limit for the VARCHAR2 buffer and gets handled as clob.
    Note that this may occur outside the app builder as well. The app builder just renders some additional items when starting that page, so it has a different size from its productive representation. On the other hand, I may start counting the size of that additional page section - I wouldn't wonder if that results in a value around 400 bytes, and this is the forgotten part...
    Unfortunately, if it actually is happening outside of the app builder, this workaround isn't very handy: Dynamic contents can't be calculated that easy all the time, so you may have cases where you just don't know in advance if you are close to the limit and have to add some item to exceed it or if you've already exceeded it or if you are far below, or close enough to actually hit it when adding just one byte...
    -Udo

  • ORA-06502 nuemeric or value error: character string buffer too small

    i am getting above error while doing
    ORA-06502 nuemeric or value error: character string buffer too small
    ORA-06512 itw_item_add_ch at line 17
    plz urgent
    CREATE OR REPLACE procedure itw_item_add_ch (header_id1 number, folio out varchar2,tariff out varchar2) as
    cursor item_add(header_id1 number) is
    SELECT
    DISTINCT c.attribute4 item_tariff_no,
    c.attribute5 item_folio
    FROM OE_ORDER_LINES_ALL b,
         mtl_system_items c
    WHERE b.flow_status_code not in ('SHIPPED','FULFILLMENT','CLOSED')
    and      b.inventory_item_id = c.inventory_item_id
    and     b.ship_from_org_id = c.organization_id
    and b.header_id = header_id1;
    begin
    for item_att in item_add(header_id1) loop
         if folio is null then
         folio := item_att.item_folio;
         else
         folio := folio||'/'||item_att.item_folio;
         end if;
         if tariff is null then
         tariff := item_att.item_tariff_no;
         else
         tariff := tariff||'/'||item_att.item_tariff_no;
         end if;
         end loop;
    end;

    if you want to find out which of your two variables are causing the problem, then use pragma exception_init along with "begin end exception" blocks within the loop.
    I've removed the procedure specification, so you can test this in SQL Plus. You need to supply a number to the Header_id1 variable something like this:
    set serveroutput on
    begin
      header_id1 number := 1; -- supply your own parameter here
      cursor Item_Add(Header_Id1 number) is
        select
              distinct c.Attribute4 Item_Tariff_No
             ,c.Attribute5          Item_Folio  
        from  Oe_Order_Lines_All    b
             ,MTL_System_Items      c
        where b.Flow_Status_Code    not in ('SHIPPED','FULFILLMENT','CLOSED')
        and   b.Inventory_Item_Id   = c.Inventory_Item_Id
        and   b.Ship_From_Org_Id    = c.Organization_Id
        and   b.Header_Id           = Header_Id1;
      exception TOO_MANY_CHARS;
      exception TOO_TARIFF_CHARS;
      pragma exception_init(TOO_MANY_CHARS, -6502);
      l_Folio varchar2(32747);
      l_Tariff varchar2(32747);
      l_Folio_Continue boolean  := true;
      l_Tariff_Continue boolean := true;
    begin
      for Item_Att in Item_Add(Header_Id1) loop
        if (l_Folio_Continue) then
          begin
            if l_Folio is null then
              l_Folio := Item_Att.Item_Folio;
            else
              l_Folio := l_Folio||'/'||Item_Att.Item_Folio;
            end if;
          exception
            when TOO_MANY_CHARS then
              dbms_output.put_line ('Foilio has too many values ');
              l_Folio_Continue := false;
              exit;
          end;
        end if;
        if (l_Tariff_Continue) then
          begin
            if l_Tariff is null then
              l_Tariff := Item_Att.Item_Tariff_No;
            else
              l_Tariff := l_Tariff||'/'||Item_Att.Item_Tariff_No;
            end if;
          exception
            when TOO_MANY_CHARS then
              dbms_output.put_line ('Tariff has too many values ');
              l_Tariff_Continue := false;
              exit;
        end if;
      end loop;
    end;
    /this is untested, so please sort out any compilation errors yourself.

Maybe you are looking for

  • How to set up a cook book

    Hi, working on a cookbook and just downloaded a trial of InDesign. Am not completely lost because I'm pretty familiar with Photoshop and Acrobat. So I want the final book to be 8"x8" a single first page and then double sided with an image on one side

  • After restoring iPod Touch to factory settings it's still connected to my account...?

    I am going to sell my iPod Touch 5th Gen so I went on my laptop and restored it to factory default. I've done this before and it disconnected an iPod Nano from my account and I was able to sell it, but this time I got a message on my laptop saying "T

  • HP DV -6 1161 tx 16inch support no longer available

    Hi All,           Im using the HP DV6 1161 tx model purchased in 2009. I updated the OS to wndows 7 home premium. Now my bluetooth and webcam dont seem to work. Also my device manager shows the following : The Hp Website no longer supports my model f

  • How do I display thumbnails for subfolders with images in Finder?

    Hello. I've settled in quite nicely with OS X but I find there's one thing I couldn't replace with a better alternative from XP and I've looked extensively for a solution but with no luck, so I figured I'd ask. It's best described with a picture (htt

  • New computer, new itunes library, lost files on ipod

    I'm not sure if this has happened to anyone, but please help me if it has!! My computer recently crashed due to an electrical storm, therefore I lost all of my files. Luckily all of my music files were already on my 30g ipod. I set up my new computer