Character string buffer too small (select list query based LOV)

Hi,
Using the select list query based LOV with a select witch is too big, you get this error.
report error:
ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
When using the Popup LOV query based LOV) then it works nice.
Can that be solved somehow?
With the Popup LOV the return value is displayed in stead of the description.

Hi Andy,
How do I incorporate your suggestion on a report ?
Example : I have
select apex_item.display_and_save(1,column1,5) col1,
apex_item.display_and_save(2,column2,5) col2 ,
apex_item.popup_from_query(3, emp_name, 'select user_name, name  empname from table2) col3
Table 2 is a long list , and I'm getting string buffer too small due to this.
Your suggestion with HTP is good but I'm not sure how to implement it for reports as I'll like the user to change the values with the select_list.
I'm not using forms as they want mulit-record on the same page.
Hope to hear back from you soon.
Thanks very much.

Similar Messages

  • 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 {code} before and after the tabular text, to preserve spacing.

  • BI Publisher Report Query Error: "character string buffer too small"

    Using apex.oracle.com, I am trying to make a Report Query (Shared Components > Report Queries) based on many columns (around 60).
    When I enter my SQL in the "Source Query" Text Area and then click Test Report I get the following error:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small In order to try to make the simplest test case possible for this, I then tried entering SQL selecting just from DUAL.
    The following SQL fails with the error mentioned above.
    SELECT
    'wibble' as a
    ,'wibble' as b
    ,'wibble' as c
    ,'wibble' as d
    ,'wibble' as e
    ,'wibble' as f
    ,'wibble' as g
    ,'wibble' as h
    ,'wibble' as i
    ,'wibble' as j
    ,'wibble' as k
    ,'wibble' as l
    ,'wibble' as m
    ,'wibble' as n
    ,'wibble' as o
    ,'wibble' as p
    ,'wibble' as q
    ,'wibble' as r
    ,'wibble' as s
    ,'wibble' as t
    ,'wibble' as u
    ,'wibble' as v
    ,'wibble' as w
    ,'wibble' as x
    ,'wibble' as y
    ,'wibble' as z
    ,'wibble' as ab
    ,'wibble' as ac
    ,'wibble' as ad
    ,'wibble' as ae
    ,'wibble' as af
    ,'wibble' as ag
    ,'wibble' as ah
    ,'wibble' as ai
    ,'wibble' as aj
    ,'wibble' as ak
    ,'wibble' as al
    ,'wibble' as am
    ,'wibble' as an
    ,'wibble' as ao
    ,'wibble' as ap
    ,'wibble' as aq
    ,'wibble' as ar
    ,'wibble' as at
    ,'wibble' as au
    ,'wibble' as av
    FROM dualRemoving the last column from this SQL query (bringing the total number of columns down to 45) as follows and then clicking "Test Report" works successfully.
    SELECT
    'wibble' as a
    ,'wibble' as b
    ,'wibble' as c
    ,'wibble' as d
    ,'wibble' as e
    ,'wibble' as f
    ,'wibble' as g
    ,'wibble' as h
    ,'wibble' as i
    ,'wibble' as j
    ,'wibble' as k
    ,'wibble' as l
    ,'wibble' as m
    ,'wibble' as n
    ,'wibble' as o
    ,'wibble' as p
    ,'wibble' as q
    ,'wibble' as r
    ,'wibble' as s
    ,'wibble' as t
    ,'wibble' as u
    ,'wibble' as v
    ,'wibble' as w
    ,'wibble' as x
    ,'wibble' as y
    ,'wibble' as z
    ,'wibble' as ab
    ,'wibble' as ac
    ,'wibble' as ad
    ,'wibble' as ae
    ,'wibble' as af
    ,'wibble' as ag
    ,'wibble' as ah
    ,'wibble' as ai
    ,'wibble' as aj
    ,'wibble' as ak
    ,'wibble' as al
    ,'wibble' as am
    ,'wibble' as an
    ,'wibble' as ao
    ,'wibble' as ap
    ,'wibble' as aq
    ,'wibble' as ar
    ,'wibble' as at
    ,'wibble' as au
    FROM dualSo the question is: Is there a hard-coded limit of 45 columns for a Source Query? Or is there something else causing this error message?
    (For information in the above example I have "Use Generic Report Layout" selected and the output format set to "PDF")
    Thanks very much in advance for any comments or suggestions,
    Andy

    Thanks for the suggestion Simon.
    I just created a view based on the 46-column SELECT statement from dual above and then set "SELECT * FROM myview" as the Source Query.
    Unfortunately I get exactly the same error.
    Thanks,
    Andy

  • HTMLDB_ITEM.POPUP_FROM_QUERY - character string buffer too small

    I am creating a updateable report with a popup_from_query item on a table with a high number of columns (40 columns) where every column should be displayed as a popup_from_query.
    I get the following error message when running the page:
    report error:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    *** It seems the longer the column list gets, the shorter the p_lov_query parameter could be.
    - Region 1: If you use only one column, your lov query fails with a statement that is 807+ characters. (if you use 806 it will work without an error).
    - Region 2: If you use only two column, you will fail just with a value of 800.
    - Region ?: I have 40 columns, now my query fails of about 30 charachters.
    * Region 1:
    select
    htmldb_item.popup_from_query(5,'x',
    'SELECT distinct '||COLUMN_NAME||' d, '||COLUMN_NAME||' r'||
    rpad(' ',807,' ')||
    ' FROM '||TABLE_NAME||' order by 1') xxxxxxxxxxxxxxxxxxxxxxxxxxxxx1
    from all_tab_columns
    where rownum < 2
    * Region 2:
    select
    HTMLDB_ITEM.POPUP_FROM_QUERY (
    44, 'x',
    'SELECT distinct '||COLUMN_NAME||' d, '||COLUMN_NAME||' r'||
    rpad(' ',800,' ')||
    ' FROM '||TABLE_NAME||' order by 1',
    least(DATA_LENGTH,60),2000
    ) xxxxxxxxxxxxxxxxxxxxxxxxxxxxx1,
    HTMLDB_ITEM.POPUP_FROM_QUERY (
    44, 'x',
    'SELECT distinct '||COLUMN_NAME||' d, '||COLUMN_NAME||' r'||
    rpad(' ',800,' ')||
    ' FROM '||TABLE_NAME||' order by 1',
    least(DATA_LENGTH,60),2000
    ) xxxxxxxxxxxxxxxxxxxxxxxxxxxxx2
    from all_tab_columns
    where data_type in ('VARCHAR2')
    I have set the region to: Use Generic Column Names (parse query at runtime only)
    Has anyone some suggestions or workaround for updateable reports with a lot of columns where popup's are needed?
    Thx Willi

    Hallo,
    Thank you a lot for that hint. But if this would be the case, why does Region 2 work then?
    Any further comments are welcome.
    Thx, Willi
    P.S.: I had reached the 2000 items (<input>) limit, but now only display less 2000 items on the page: "Your browser sent a request that this server could not understand.
    mod_plsql: /pls/htmldb/wwv_flow.accept HTTP-400 Too many arguments passed in.
    Got 9016 parameters. Upper limit is 2000"

  • Report error: numeric or value error: character string buffer too small.

    Full Details:
    report error:
    ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too small.
    MS Access runs this query but when I try to call a 'List of Values' in APEX that is in excess of 800 the error above displays. If I use a 'Pop Up' it will work but splits the list at 500. This is annoying and slower as I would like to be able to display all 850+ items in a named list of values. How do I increase the buffer size?
    Kind Regards,
    Steve

    Steve,
    Could you please post the query you're using? You're most like hitting one of two possible varchar2 limitations. If you're calling the apex_item API in your SQL query to render the select list, then you're limited to 8000 characters, this your option values and HTML code used to render this. In this case using the "XL" versions of the APIs might help, e.g. select_list_from_query_xl, because those return CLOBs. If you're already using those or if you're using the built-in display type "select list", then you could potentially hit the 32k character limit of varchar2 values in PL/SQL. In that case the best alternative is using a popup LOV instead.
    Regards,
    Marc

  • "Character String Buffer too small" Classic Report Apex 3.2.1

    Hello Everyone,
    I know it is very old version I am discussing here but that is what we have in our environment, would really appreciate if anyone can help out.
    I have a classic report with the below query, in this I have added a filter using a select list item (P70_GROUP).
    SELECT vws.ServerID AS Display_ID,       vws.ServerID AS ID,       vws.Hostname,       vws.ServerStatus,       vws.SiteName AS Site,       vws.Client,       vws.CoreHours,       vws.Patch_Notes,       vws.PATCH_DEP,       vws.Patch_Day,       vws.PATCH_GROUPID,       vws.PATCH_TIMEID AS Time     FROM VW_Live_Support vws LEFT JOIN W_Patch_Groups wpg     ON (vws.Patch_GroupID = wpg.ID) WHERE vws.Deleteable      = 'N'   AND NVL(wpg.Ignore, 'N') = 'N'   AND ((:P70_GROUP > 1 AND vws.PATCH_GROUPID = :P70_GROUP) OR         (:P70_GROUP = 1 AND vws.Patch_GroupID IS NULL)      OR         (NVL(:P70_GROUP,0) = 0))   AND ( INSTR(UPPER(vws.HostName),    UPPER(NVL(:P70_SEARCH,vws.HostName)))    > 0 OR INSTR(UPPER(vws.ServerStatus), UPPER(NVL(:P70_SEARCH,vws.ServerStatus))) > 0 OR INSTR(UPPER(vws.SiteName),    UPPER(NVL(:P70_SEARCH,vws.SiteName)))    > 0 OR INSTR(UPPER(vws.Client),      UPPER(NVL(:P70_SEARCH,vws.Client)))      > 0 OR INSTR(UPPER(vws.CoreHours),    UPPER(NVL(:P70_SEARCH,vws.CoreHours)))    > 0 OR INSTR(UPPER(vws.Patch_Notes),  UPPER(NVL(:P70_SEARCH,vws.Patch_Notes)))  > 0       )
    Issue is when i select a group from the list I am getting
    "report error:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small".
    one unusual thing I have noticed here is when I select "All Groups" which returns 0, it is running fine and returning 3700 rows but when I select any group which returns some 10-20 rows I am getting the above error.
    can't understand why this is, please help me out.
    Regards,
    Tauceef

    Tauceef wrote:
    Thanks alot for your prompt response
    Let me add some more into the issue I forgot to add.
    It is somewhat similar to what Michael has mentioned in his first post.
    Above said report is a Tabular form and there are 3 select lists in it out of which one list is too long (Group list), when I hide it report works for all the groups.
    That should have been made clear in the original post. Reports and tabular forms are not the same thing. There's much more that can go wrong on tabular forms, including hitting the LOV size limit of 32KB for a select list item. (Obviously if you hit this limit for a single item then you've automatically hit it the report row limit as well.)
    I have explained them about the LOV that when we remove that LOV it works fine but they need that list because it is a updatable value.
    As suggested by Michael, I have tried Substr, which also works fine for all the groups.
    I would suggest client to have a short name of the groups and use it as a temporary solution.
    You should use a Pop-up LOV control for large lists of options. Purely as a usability consideration—irrespective of APEX implementation limits—select lists should only be used in cases where there are a maximum of around 200 options.
    Regarding Debugging: I am not getting that option when I run the application as a developer, checked the application properties Debugging option is selected as Yes, don't know why it is not available.
    That's not connected to this problem. Open a new thread on that topic if you want to investigate and fix it.
    One more confirmation from you guys please, I have also suggested them to upgrate the environment to the latest version, hoping this will resolve the issue, please confirm?
    In the latest version also we have same size (32KB) limit or it has been increased?
    The 32KB limits for select lists and report rows are not documented but are still present in APEX 4.2 (and in APEX 5.0 to the best of my current knowledge).

  • Checkbox Item: character string buffer too small (APEX 4.0. - 4.2.)

    Hi all,
    I'm currently running the Oracle Application Express 4.0.2 on the Oracle DB 11g and thinking about the APEX upgrading to current 4.2. version. We have there quite big application used by the inernal employees so prior I need to test, if the migration will work.
    I installed the new server with database and the APEX 4.2. and import the current application. Everything seems to working good except few checkboxes, which returns me the error: "ORA-06502: PL/SQL: numeric or value error: character string buffer too small."
    LOV (Source) Code of Checkbox Item:
    SELECT email as display_value, id as return_value
    FROM users
    WHERE <some conditions>;
    In the current version 4.0.2. I get the checkbox item (total count of the rows approx. 650), but in the 4.2. I get this "string buffer too small" error and the page could not be rendered (if I add to the same query limitation: "rownum<242" it will display the item).
    Could you please help me with this issue? Any idea, what I should set up in the new APEX to get the same results or you see there any limitation, why it does not work in the new version, but in the old version the same SQL works fine?
    Thank you all in advance.
    Regards,
    Tomas.

    1007462 wrote:
    Hi all,Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "1007462".
    I'm currently running the Oracle Application Express 4.0.2 on the Oracle DB 11g and thinking about the APEX upgrading to current 4.2. version. We have there quite big application used by the inernal employees so prior I need to test, if the migration will work.
    I installed the new server with database and the APEX 4.2. and import the current application. Everything seems to working good except few checkboxes, which returns me the error: "ORA-06502: PL/SQL: numeric or value error: character string buffer too small."
    LOV (Source) Code of Checkbox Item:
    SELECT email as display_value, id as return_value
    FROM users
    WHERE <some conditions>;
    In the current version 4.0.2. I get the checkbox item (total count of the rows approx. 650), but in the 4.2. I get this "string buffer too small" error and the page could not be rendered (if I add to the same query limitation: "rownum<242" it will display the item).
    Could you please help me with this issue? Any idea, what I should set up in the new APEX to get the same results or you see there any limitation, why it does not work in the new version, but in the old version the same SQL works fine?The total size of the HTML generated for an LOV-based item in APEX is restricted to 32K (this limit applies to every version). Why you are hitting this limit in the new instance may be due to differences in data or the database configuration (e.g. character set) rather than changes introduced in APEX.
    Is the data exactly the same? Is the database configuration the same? When you limit the number of rows so the checkboxes are displayed and view the page source, is there any difference in the HTML used to render the checkbox form elements between the two versions?
    That said, from a usability perspective 650 LOV options is rather a lot, and your application may very well outgrow this limit naturally in any version of APEX as more users as added. It is probably worthwhile thinking about other ways to display these options.

  • LOV - PL/SQL: numeric or value error: character string buffer too small

    I have a field set to 'text field with autocomplete' and now that the data that is used for the LOV has increased dramatically it returns the following error 'ORA-06502: PL/SQL: numeric or value error: character string buffer too small'. Through trial and error I determined that if I restricted the number of rows returned using rownum < nnn then it would work. I then determined that I could use the trim and substring functions and remove the rownum restriction and it would work. Below is the LOV query. I have seen a couple of other posts similar to my problem and one of them asked if there was a way to increase the buffer size, but it was never answered. Is there a way, such as a parameter setting, that I could increase the buffer size for LOVs?
    select distinct substr(trim(item_requested),1,50) d
    from consolidated_components
    order by 1
    Thank you.

    Hi Scott
    Thanks very much for jumping in here.
    No, I didn't use the wizard to create the page. It was a manual operation but to tell you the truth the page has been changed so many times as I was working on different functionality and appearance that anything could have happened. I ended up having to manually create row processing processes and delete other processes, creating and hiding buttons, changing the way I'm passing item values, etc. I realize regardless of what I do as a developer the software should be able to handle all changes through it's interface but I've been in this business long enough to be realistic.
    I also could have done something blatantly stupid as I continue to learn this product. For those of us not yet totally comfortable with all the web development technology, Javascript, AJAX, etc., but are asked to develop applications that work best using those technologies sometimes we make elementary blunders.
    Thanks very much for your help. It is indeed appreciated.
    -gary

  • Character string buffer too small problem

    hi, guys:
    I have a question that may be silly, I got error "ORA-06502: PL/SQL: numeric or value error: character string buffer too small" when I run a query. if I uncomment "and rox.status='Active'" condition, I do not have the error. I guess it is related to some specific rows. I checked online, it looks the length of some varchar2 variable is not enough, but I just cannot find cause. I also notice there might be an error about v_level in the function, I should use number instead of varchar2 type. but after I changed the type of v_level, the error is still there. I would be cautious as this is a legacy system. Could anyone help me on this problem?
    I have a query like this:
    select *
    from registration_offender_xref rox
    where SOR_OFFENDER_DETAILS.get_offender_level(rox.offender_ID)=3
    --and rox.status='Active'
    and rox.end_registration_date is not null;I get error message as :
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "SORS.SOR_OFFENDER_DETAILS", line 124
    06502. 00000 - "PL/SQL: numeric or value error%s"
    SOR_OFFENDER_DETAILS.get_offender_level return a number value from 1 to 3, or a null value. Here is the code
      function get_offender_level(p_offender_id IN NUMBER) return NUMBER as
          sex_offender_flag number;
          tier_level number;
          override_num number;
          v_status  varchar2(10);
          v_aggravated  varchar2(10);
          v_habitual  varchar2(10);
          v_level  varchar2(10);
          cursor tierNum is  -- as May 22, 2008 per HKT of DOC (past portal code), Level/Tier is displayed for all offenders
                   select max(c.tier)
          from sor_offense o, sor_offense_code c
                   where o.offender_id = p_offender_id
                   and o.OFFENSE_CODE = c.CODE_ID
          and upper(o.status) = 'ACTIVE';
      begin
          select count(*)
          into sex_offender_flag
          from registration_offender_xref rox
          where rox.offender_ID=p_offender_id
          and reg_type_ID=1;
          if sex_offender_flag>0 then
              OPEN tierNum;
              FETCH tierNum INTO v_level;
                if tierNum%NOTFOUND then
                tier_level := null;
                end if;
              CLOSE tierNum;
              select tier_overRide into overRide_Num
              from registration_offender_xref
              where offender_id = p_offender_id
              and reg_type_id = 1;
              if overRide_Num is not null then
                v_level:=overRide_Num;
              end if;
              --dbms_output.put_line('overRide_Num:'||overRide_Num);   
              --dbms_output.put_line('after override:'||p_level);
    /*error line*/        
                select status,  decode(aggravated,'Y','Yes','No') aggravated,
               decode(habitual,'Y','Yes','No') habitual
              into v_status,  v_aggravated, v_habitual
              from registration_offender_xref
              where offender_id = p_offender_id
              and reg_type_id = 1;
                if upper(v_status) in ('COMPLETED', 'DECEASED', 'DELETED') then
                   v_level := null;
                end if;
               --dbms_output.put_line('before final:'||p_level);
                if v_aggravated = 'Yes' or v_habitual = 'Yes' or v_level = 3 then
                   v_level := 3;
                end if;
               --dbms_output.put_line('final:'||p_level);
                if override_num is not null then
                   v_level := overRide_Num;
                end if;   
                   else
                v_level:=null;
          end if;
          return v_level;
      end get_offender_level;Thanks a lot!
    Sam
    Edited by: lxiscas on May 23, 2013 8:38 AM
    Edited by: lxiscas on May 23, 2013 8:41 AM
    Edited by: lxiscas on May 23, 2013 9:01 AM

    I'm not suggesting this is your problem, but
    select status
    into v_status,
    from registration_offender_xref But you have declared
          v_status  varchar2(10);Much better to declare things like this
          v_status  registration_offender_xref.status%type;That way you know your variable is declared with a proper length, if the column length ever changes ... your code doesn't go kaboom.
    Cheers,

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

  • Numeric or value error: character string buffer too small

    Hi,
    I have no problem with this code :
    select htmldb_item.text(3,nom,20) nom,
    htmldb_item.select_list_from_query(9,v_urba_rue.ref_fantoir,'select distinct(nom_voie),v_urba_rue.ref_fantoir from adresse,v_urba_rue where adresse.ref_fantoir(+)=v_urba_rue.ref_fantoir and ref_commune=20 and v_urba_rue.ref_fantoir between 1280 and 1370') rue
    from personne,participe,adresse,v_urba_rue
    where ...
    but when i modify :
    ...and v_urba_rue.ref_fantoir between 1280 and 1400') rue...
    i have this error :
    ORA-06502 PL/SQL: numeric or value error: character string buffer too small
    any solution?
    thank you very much

    Is this the same posting as
    ORA-06502 numeric or value error string

  • PL/SQL: numeric or value error (character string buffer too small)

    Hi All,
    Below is the procedure used to send notifications. It was working fine in previous DB version :- 10.1.0.5.0 and there was recent upgrade to 11.2.0.2.0.
    I complies fine, but when executing it throws the error.
    PROCEDURE PROC_STATUS_MAIL_UNADJ IS
           K_BOUNDARY CONSTANT VARCHAR2(1000) := 'a1b2c3d4e3f2g1';
          l_analysis_report  VARCHAR2(32767); --empty_clob; --clob :=
          l_header VARCHAR2(1000);
          l_footer VARCHAR2(200);
          cnxn UTL_SMTP.connection;
          cursor cloc is select location_id from locations order by location_id asc;
          loc_id cloc%rowtype;
    BEGIN
      dbms_output.enable (1000000);
         FOR loc_id in  cloc
         loop
         l_analysis_report := '<style type="text/css">
        <!--.style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-style: normal; color: #FF0000}-->
        <!--.sidebar1 { font-family: Arial, Helvetica, sans-serif; font-size: 10px}-->
        <!--.text { font-family: Arial, Helvetica, sans-serif; font-size: 12px}-->
        </style>
        <center><b><font face="Arial">Run Summary Report'
                    || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI AM') || '<br><br></font></b></center>'
                    || ' <div align="center"><table width="95%" border="1" cellspacing="0" cellpadding="1" </div>'
                    || '<span style="font-size: 10pt; font-family: Arial"> </span> '
                    || '<tr bgcolor=b4b4b4><td align="center"> <font size="3"> <b>'
                    || 'Analysis</b></td><td align="center"><font size="3"> <b>'
                    || 'Start Time</b></td><td align="center"><font size="3"> <b>'
                    || 'End Time</b></td><td align="center"><font size="3"> <b>'
                    || 'Run Duration (mins)</b></td><td align="center"><font size="3"> <b>'
                    || 'Status</b></font></td></tr> ' || UTL_TCP.CRLF;
                    FOR curr_refresh IN (SELECT AN.ANALYSIS_ID,AN.NAME ANALYSIS_NAME,TO_CHAR(ARH.RUN_START_TIME,'DD/MM/YYYY HH:MI:SS') START_TIME,
                                         TO_CHAR(ARH.RUN_END_TIME,'DD/MM/YYYY HH:MI:SS')END_TIME,
                                         ROUND(((ARH.RUN_END_TIME-ARH.RUN_START_TIME)*24*60),2) RUN_TIME_SECS,ARH.JOB_STATUS STATUS
                                         FROM
                                         RUN_HISTORY ARH,ANALYSES AN
                                         WHERE
                                         AN.ANALYSIS_ID=ARH.ANALYSIS_ID
                                         AND AN.CYCLE_IND_ID IN (1,3)
                                         AND ARH.RUN_START_TIME>TO_DATE(SYSDATE-30)
                                         AND ARH.JOB_NAME LIKE 'RHS_QU%'                                  
                                         AND AN.LOCATION_ID = loc_id.location_id
                                         AND ARH.JOB_STATUS='Completed'
                                         ORDER BY ARH.RUN_START_TIME DESC)
                           LOOP
                       l_analysis_report  := l_analysis_report ||'<tr><td align="center">'|| curr_refresh.analysis_name
                          || '</td><td align="center">' || curr_refresh.start_time || '</td><td align="center">'
                          || curr_refresh.end_time || '</td><td align="center">'|| curr_refresh.RUN_TIME_SECS ||
                          '</td><td align="center">'|| curr_refresh.status ||
                          '</td> </tr>' || UTL_TCP.CRLF;
                      exit when length (l_analysis_report) > 32500;
                   END LOOP;
                  l_analysis_report := l_analysis_report || '</table><br><br>';
                   l_footer := UTL_TCP.CRLF ||'<b> Note: This is an auto generated email. Please do not reply to it. Contact the IT team for any further information.</b>'||  UTL_TCP.CRLF;
                   FOR curr_email IN (SELECT GLOBAL_NAME INSTANCE_NAME,
                                      EU.EMAIL_USER_LAST_NAME last_name, EU.EMAIL_USER_FIRST_NAME ACNAME,
                                      EU.EMAIL_USER_EMAIL_ID,loc.LOCATION_NAME LOC_NAME,
                                      '[email protected]' MAIL_FROM
                                      FROM
                                      RHS_EMAIL_USER EU,LOCATIONS LOC,GLOBAL_NAME
                                      WHERE EU.LOCATION_ID=LOC.LOCATION_ID
                                      AND EU.LOCATION_ID=loc_id.location_id
                                  ) LOOP
                cnxn := UTL_SMTP.open_connection('smtprelay.inc.com', 25);
                UTL_SMTP.helo(cnxn, 'smtprelay.inc.com');
                UTL_SMTP.mail(cnxn, '[email protected]');
                UTL_SMTP.rcpt(cnxn, curr_email.EMAIL_USER_EMAIL_ID);
                      l_header := 'MIME-Version: 1.0'||'
    To: ' || curr_email.last_name || ' <' || curr_email.EMAIL_USER_EMAIL_ID || '>
    From: ' || curr_email.mail_from || '
    Subject: Un-Adjusted Analysis Report for ' || curr_email.loc_name || ' Location from' || curr_email.instance_name || ' on ' || to_char(sysdate, 'DD-MON-YYYY') || '
    Reply-To: [email protected]
    Content-Type: text/html;' || UTL_TCP.CRLF || UTL_TCP.CRLF;
                UTL_SMTP.data(cnxn, l_header || l_analysis_report || l_footer);
                UTL_SMTP.quit(cnxn);
                END LOOP;
                END LOOP;
    END PROC_STATUS_MAIL_UNADJ;
    Error :-
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "SYS.UTL_SMTP", line 591
    ORA-06512: at "SYS.UTL_SMTP", line 497
    ORA-06512: at "SYS.UTL_SMTP", line 503
    ORA-06512: at "RISK_HISTORY.PKG_RHS_EMAIL_NOTIFY", line 206
    ORA-06512: at "RISK_HISTORY.PKG_RHS_EMAIL_NOTIFY", line 414
    ORA-06512: at line 2Can you please let me know if there is any issue with code or any upgrade issue ?
    Regards,
    Sunny
    Edited by: k_17 on Oct 13, 2011 12:07 PM

    Hi Helios,
    Many thanks for your reply.
    I am able to figure out the issue. In the code we have
    l_analysis_report  := l_analysis_report ||'<tr><td align="center">'|| curr_refresh.analysis_name
                          || '</td><td align="center">' || curr_refresh.start_time || '</td><td align="center">'
                          || curr_refresh.end_time || '</td><td align="center">'|| curr_refresh.RUN_TIME_SECS ||
                          '</td><td align="center">'|| curr_refresh.status ||
                          '</td> </tr>' || UTL_TCP.CRLF;
                      exit when length (l_analysis_report) > 32500;where "l_analysis_report VARCHAR2(32767);"
    The issue is report has more characters, and when executing it throws the error " ORA-06502: PL/SQL: numeric or value error: character string buffer too small ".
    Can you please let me know how to have more characters/data in the report. Will CLOB help if yes, please let me know how to use it.
    Kindly suggest some options.
    Regards,
    Sunny

  • Character string buffer too small error in tabular form

    Hi Folks,
    One of my tabular forms suddenly stopped working out of the blue after 3 months of working perfectly. So I've run into the debug and looks like something went wrong rendering my LOV as below:
         0.16968     0.00328     ...Execute Statement: begin begin SELECT TIME_DISPLAY D, TIME_RETURN R bulk collect into wwv_flow_utilities.g_display,wwv_flow_utilities.g_value FROM TS_HOURS ORDER BY 2; end; end;     4     
    8
         0.17292     0.03912     ...Execute Statement: begin begin select /*+ cardinality(t 10) */ disp, val bulk collect into wwv_flow_utilities.g_display,wwv_flow_utilities.g_value from table(wwv_flow_utilities.get_temp_lov_data(2)) t order by insert_order, disp; end; end;     4     
    100
         0.21211     0.00224     report error: ORA-06502: PL/SQL: numeric or value error: character string buffer too smallI've looked around and saw few others having same issues but nothing that's like mine. Could someone please help me find what the issue is? THanks.
    I am using Apex 4.1.1

    Hi Andre, I have figured out the issue.
    You were correct about the 32K limit. However it applies to the whole tabular form not to do with the particular LOV.
    I tweaked my other LOV's (with 200 return value) to display fewer and this issue was resolved. I think there wasn't enough left for my 60 row LOV by the time APEX engine got to it which renders after the bigger LOV was rendered.
    I think Advisor should have some kind of feature to check forms against 32k limit. Otherwise you wake up one morning and application broke after working 3 months perfectly.

  • Error in notification - "character string buffer too small"

    Hi All,
    Hope everyone is doing great...
    I have issue with one of the procedure which sends out status email for the reports. Below is the code.
    It worked fine from last six months but today it failed because of the length of characters (more reports are added).
    The variable "l_an_report" is VARCHAR and it has crossed it limit so gave the below error. Not sure how to handle the report so that it includes all the data.
    Also please let me if this is good solution :- Have the report status in excel sheet and attach to the email.
    If its fine please let me know how i can achieve this and any prerequisite from network team we need to get?
    ERROR :-
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "REPORT_STAT.PACKG_EMAIL", line 441
    ORA-06512: at line 2
    Procedure PRC_SUMMARY IS
          l_an_report varchar2(32767);
          l_header VARCHAR2(1000);
          cnxn UTL_SMTP.connection;
          P_job           NUMBER (10)    DEFAULT TO_NUMBER (TO_CHAR (SYSDATE,'YYYYMMDD'));
    BEGIN
                          l_an_report := '<style type="text/css">
    <!--.style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-style: normal; color: #FF0000}-->
    <!--.sidebar1 { font-family: Arial, Helvetica, sans-serif; font-size: 10px}-->
    <!--.text { font-family: Arial, Helvetica, sans-serif; font-size: 12px}-->
    </style>
    <center><b><font face="Arial">Summary Report '
                || '<br><br></font></b></center>'
                || ' <div align="center"><table width="90%" border="1" cellspacing="0" cellpadding="1"'
                || 'style="font-size: 10pt; font-family: Arial" > '
                || '<tr bgcolor=b4b4b4><td align="center"> <font size="3"> <b>'
                || 'Report</b></td><td align="center"><font size="3"> <b>'
                || 'Run Duration </b></td><td align="center"><font size="3"> <b>'
                || 'Status</b></font></td></tr> ' || UTL_TCP.CRLF;
                    FOR curr_refresh IN (SELECT
                                         AN.NAME report_NAME,
                                         ROUND(((ARH.RUN_END_TIME-ARH.RUN_START_TIME)*24*60),2) RUN_TIME,
                                         ARH.JOB_STATUS STATUS
                                         FROM
                                         REPORT_HISTORY ARH,REPORT AN
                                         WHERE
                                         ARH.RUN_START_TIME>TO_DATE(SYSDATE-93)
                                         AND AN.report_ID=ARH.report_ID
                                         and arh.JOB_NAME like 'QA%'
                                         and arh.JOB_STATUS='Completed')
                                  LOOP
              l_an_report  := l_an_report ||
              '<tr><td align="center">'|| curr_refresh.report_name|| '</td><td align="center">'|| curr_refresh.RUN_TIME ||
              '</td><td align="center">'|| curr_refresh.STATUS ||
               '</td><td align="center">' || UTL_TCP.CRLF;                      
                exit when length (l_an_report) > 32767;                   
          END LOOP;
           l_an_report := l_an_report || '</table><br><br>';
                FOR curr_email IN (SELECT global_name instance_name,
                REU.EMAIL_USER_LAST_NAME last_name,
                REU.EMAIL_USER_FIRST_NAME first_name,
                REU.EMAIL_USER_EMAIL_ID,
                '[email protected]' mail_from
                                 FROM EMAIL_USER REU, EMAIL_GROUP REG,GLOBAL_NAME
                                             WHERE REU.EMAIL_GROUP_ID = REG.EMAIL_GROUP_ID
                                                   AND REG.EMAIL_GROUP_NAME ='IT') LOOP
                cnxn := UTL_SMTP.open_connection('smtprelay.ats.com', 25);
                UTL_SMTP.helo(cnxn, 'smtprelay.ats.com');
                UTL_SMTP.mail(cnxn, '[email protected]');
                UTL_SMTP.rcpt(cnxn, curr_email.EMAIL_USER_EMAIL_ID);
                   l_header := 'MIME-Version: 1.0'||'
                   To: ' || curr_email.last_name || ' <' || curr_email.EMAIL_USER_EMAIL_ID || '>
                   From: ' || curr_email.mail_from || '
                   Subject: Summary Report for ' || curr_email.instance_name || ' on ' || to_char(sysdate, 'DD-MON-YYYY') || '
                   Reply-To: [email protected]
                   Content-Type: text/html;' || UTL_TCP.CRLF || UTL_TCP.CRLF;
                UTL_SMTP.data(cnxn, l_header || l_an_report);
                UTL_SMTP.quit(cnxn);
          END LOOP;
    END PRC_SUMMARY;Please share your thoughts.
    Regards,
    Sunny

    >
    It worked fine from last six months but today it failed because of the length of characters (more reports are added).
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    >
    The error is because you don't check the length of 'l_an_report' until it is already too long.
    This code checks the length AFTER adding to it.
    >
    l_an_report := l_an_report ||
    '<tr><td align="center">'|| curr_refresh.report_name|| '</td><td align="center">'|| curr_refresh.RUN_TIME ||
    '</td><td align="center">'|| curr_refresh.STATUS ||
    '</td><td align="center">' || UTL_TCP.CRLF;
    exit when length (l_an_report) > 32767;
    >
    You need to test the length of the new string to be added to make sure it won't cause 'l_an_report' to be too long
    -- add a new variable in the declare section
    v_new_string VARCHAR2(2000);
    -- in loop do calc
    v_new_string := '<tr><td align="center">'|| curr_refresh.report_name|| '</td><td align="center">'|| curr_refresh.RUN_TIME ||
              '</td><td align="center">'|| curr_refresh.STATUS ||
               '</td><td align="center">' || UTL_TCP.CRLF;                      
    -- test length
    IF (length(v_new_string) + length (l_an_report) > 32767 THEN EXIT;But as others have said if you need to handle lengths > 32767 then use an attachment as shown in the links provided.

  • Wrong forum!!!  character string buffer too small problem

    Hi,
    I'm using a pl/sql procedure which builds a string held by a VARCHAR2 variable, however i've just discovered that in certain situations this string exceeds 2000 characters and i get this error:-
    ORA-20500: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    How can i stop this from happening. Do i need to use another datatype??
    PROCEDURE p_build_string(p_string_to_build IN OUT VARCHAR2
    ,p_string_to_add IN VARCHAR2
    ,p_delimiter IN VARCHAR2) IS
    BEGIN
    /* initialise string */
    IF INSTR(p_string_to_add,'''') <> 0 THEN
    IF p_string_to_build IS NULL THEN
    p_string_to_build := ''''||REPLACE(p_string_to_add,'''','''''')||'''';
    l_number_of_string_items := 1;
    ELSE
    p_string_to_build := p_string_to_build||p_delimiter||''''||REPLACE(p_string_to_add,'''','''''')||'''';
    l_number_of_string_items := l_number_of_string_items + 1;
    END IF;
    ELSE
    IF p_string_to_build IS NULL THEN
    p_string_to_build := ''''||p_string_to_add||'''';
    l_number_of_string_items := 1;
    ELSE
    p_string_to_build := p_string_to_build||p_delimiter||''''||p_string_to_add||'''';
    l_number_of_string_items := l_number_of_string_items + 1;
    END IF;
    END IF;
    dbms_output.put_line(l_number_of_string_items || ' ' ||p_string_to_build);
    END;
    Message was edited by:
    david_wood

    I'm not suggesting this is your problem, but
    select status
    into v_status,
    from registration_offender_xref But you have declared
          v_status  varchar2(10);Much better to declare things like this
          v_status  registration_offender_xref.status%type;That way you know your variable is declared with a proper length, if the column length ever changes ... your code doesn't go kaboom.
    Cheers,

Maybe you are looking for

  • Closing the browser

    hi Here i have a requirement such that in wdj application there is a button logoff when i click on that i have to close the borwser (on which the application is running )also...... pls help me Warm Regards Shanto Aloor Edited by: Armin Reichert on Ap

  • Unable to connect computers to a Windows Server 2012

    I have two brand new Windows 7 Professional computers that I want to connect to a Windows Server 2012 Essentials.  I'm able to download the connector software but when it is searching for the server I receive a message that "Cannot locate or identify

  • Internal.text parsed by XML object ?

    Is it possible to use the XML object to parse internal xml instead of loading an external file? I am writing an application that converts arrays & objects into xml. In my development, I am displaying the xml in a text field on the stage. In testing I

  • Headphone are pulsing

    My headphones are not working properly. They just pulse the music. Sound effects are off. Sound is great thru speakers... Any thoughts? Mike

  • Pooled tables m_vmvlb and m_vmvla in ECC6.0

    Hi, We are upgrading system from 4.6C to ECC6.0. But in ECC6.0 pooled tables m_vmvlb and m_vmvla have been deleted. Now these tables have been used in a customize program. So do we need to create the tables with similar structure or there is any OSS