ORA-06502 PL/SQL Error

Hi All
Currently I am working on .net based application and Oracle 8.0.6.00 (Multi language Support - (Japanese/English ))as backbend .
The above mention error is occurring from last few days on our production server when user is trying to save data .
I have already gone through all packages and procedure used in my application .
but i didn't find any conversion error .
Main Problem is that some time data is save properly even if error is occurred and some time it not saving data in to the DB. and the same error we are trying to reproduce on development server but it is not reproducing ...
I also checked all NLS Setting of my DB .but still in vague about this error
Can some help me......
Thanks & Regards
Shrirang
Message was edited by:
user528219

As you said
Main Problem is that some time data is save properly even if error is occurred
and some time it not saving data in to the DB. and the same error we are trying to
reproduce on development server but it is not reproducing ...
I also checked all NLS Setting of my DB .but still in vague about this error
Can some help me......
Hi Khurram ,
Thanks for reply
the problem is not related any perticular code its big package which we call
to load , modify and save data . i have checked all code . my filed size is 4 time
more then specified size by user for a perticular field.
can you plz. suggest me any other way to solve this
SQL> CREATE OR REPLACE PACKAGE error_06502 AS
  2  FUNCTION  a RETURN VARCHAR2;
  3  END error_06502;
  4  .
SQL> /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY error_06502 AS
  2    v1   NUMBER:='A';<----------------Damn it is an headache
  3    FUNCTION a RETURN VARCHAR2 AS
  4      BEGIN
  5       RETURN 'No Error';
  6    END a;
  7    BEGIN
  8      DBMS_OUTPUT.PUT_LINE ('Error is going to trapped for assigining variable v1..');
  9      EXCEPTION WHEN OTHERS THEN
10      DBMS_OUTPUT.PUT_LINE ('Now error is handled..');
11  END error_06502;
12  .
SQL> /
Package body created.
First time
SQL> EXEC DBMS_OUTPUT.PUT_LINE(error_06502.a);
BEGIN DBMS_OUTPUT.PUT_LINE(error_06502.a); END;
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "SCOTT.ERROR_06502", line 2
ORA-06512: at line 1
Now see here
SQL> EXEC DBMS_OUTPUT.PUT_LINE(error_06502.a);
No Error
PL/SQL procedure successfully completed.See why error showed at first glance but not at second time why??
First Time
Whenever you execute the package first time it initiliased once for each
session,when i run this package first time package initialisation going to first time
and the assignment makes in variable v first time and raise the error though i
have exception block in my executable section which is responsible only to handle
errors that is raised in excutable section.
Second Time
Though package intitliasation is failed at first time (intiliasation dont occur properly
first time) ,Oracle marks the package is initialised and will run continously without
any error and return the string 'No Error' within the lenght of yours session when
you will drop yours session and again try to run the package it will raise the same
error first time
SQL> DISCONNECT
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> CONN scott/tiger
Connected.
SQL> EXEC DBMS_OUTPUT.PUT_LINE(error_06502.a);
BEGIN DBMS_OUTPUT.PUT_LINE(error_06502.a); END;
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "SCOTT.ERROR_06502", line 2
ORA-06512: at line 1.
SQL> SET SERVEROUTPUT ON
SQL> EXEC DBMS_OUTPUT.PUT_LINE(error_06502.a);
No Error
PL/SQL procedure successfully completed.Check your package variable assignment and error handling exception
properly,you had better to make assignment default value in the executable
section rather in the declaration section.In declartion section just declare the
variable but alls assignment should goes at executable section with definging the
exception which will handle the error nicely.
SQL> CREATE OR REPLACE PACKAGE BODY error_06502 AS
  2      v1   NUMBER;
  3    FUNCTION a RETURN VARCHAR2 AS
  4      BEGIN
  5       RETURN 'No Error';
  6    END a;
  7    BEGIN
  8       DBMS_OUTPUT.PUT_LINE ('Error is going to trapped for assigining variable v1..');
  9       v1:='A';
10      EXCEPTION WHEN OTHERS THEN
11      DBMS_OUTPUT.PUT_LINE ('Now error is handled..');
12  END error_06502;
13  .
SQL> /
Package body created.
SQL> EXEC DBMS_OUTPUT.PUT_LINE(error_06502.a);
Error is going to trapped for assigining variable v1..
Now error is handled..
No Error
PL/SQL procedure successfully completed.----------------------------------------------------------------------------------------------------------------
In my last post there would be another reason for this error i would code it here again..
May be the column you are storing the sequence in is defined as NUMBER2(6) to VARCHAR2(2). Some time ORACLE implicitly convert it if you have valid data in varchar2(2) column like 1,2,3 but if 1A,2A
e.g
SQL> DECLARE
  2  a   NUMBER(6);
  3  BEGIN
  4  a:='1';
  5  END;
  6  .
SQL> /
PL/SQL procedure successfully completed.
SQL> DECLARE
  2  a   NUMBER(6);
  3  BEGIN
  4  a:='1a';
  5  END;
  6  .
SQL> /
DECLARE
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 4If none of these reason which i had mentioned please let us know to share yours
workaround.
Khurram

Similar Messages

  • ORA-06502: PL/SQL: error TABLE OF BOOLEAN INDEX BY BINARY_INTEGER;

    Hi,
    I've a Compiled Body Package which code I described below:
    create or replace
    PACKAGE body emp_pkg
    IS
    TYPE boolean_tabtype2
    IS
      TABLE OF BOOLEAN INDEX BY BINARY_INTEGER;
      valid_jobs boolean_tabtype2; 
    PROCEDURE add_employee(
        first_name employees.first_name%TYPE,
        last_name employees.last_name%TYPE,
        deptid employees.department_id%TYPE,
        jobid employees.job_id%type)
    IS
    BEGIN
      IF valid_deptid(deptid) THEN
      if valid_jobid(jobid) then
                  INSERT
                  INTO employees
                      employee_id,
                      first_name,
                      last_name,
                      email,
                      hire_date,
                      job_id,
                      department_id
                    VALUES
                      employees_seq.NEXTVAL,
                      first_name,
                      last_name,
                      SUBSTR(first_name,1,1)
                      ||SUBSTR(last_name,1,7)
                      ||'@buongio.com',
                      sysdate,
                      'SA_REP',
                      deptid
         ELSE
            RAISE_APPLICATION_ERROR (-20204, 'Invalid job ID. Try again.');
          END IF;
    END add_employee;
    PROCEDURE init_jobs
    is
    begin
    FOR rec IN
      (SELECT job_id FROM jobs
      LOOP
        valid_jobs(rec.job_id):=true;
      END LOOP;
    END init_jobs;
    function valid_jobid(
        jobid employees.job_id%type)
      return boolean
    is
    BEGIN
    return valid_jobs.exists(jobid);
    EXCEPTION
    WHEN no_data_found THEN
    dbms_output.put_line('no valid');
      RETURN FALSE;
    END valid_jobid ;
    BEGIN
      init_jobs;
    END emp_pkg;and the server gives me the next output
    ORA-06502: PL/SQL: error : error de conversión de carácter a número numérico o de valorI suspect that the problem is the procedure init_jobs but I don't Know what could I do to resolve it.
    Thanks in advance...

    sorry
    I forget to remove it,
    the code:
    create or replace
    PACKAGE body emp_pkg
    IS
    TYPE boolean_tabtype2
    IS
      TABLE OF BOOLEAN INDEX BY BINARY_INTEGER;
      valid_jobs boolean_tabtype2; 
    PROCEDURE add_employee(
        first_name employees.first_name%TYPE,
        last_name employees.last_name%TYPE,
        deptid employees.department_id%TYPE,
        jobid employees.job_id%type)
    IS
    BEGIN
      if valid_jobid(jobid) then
                  INSERT
                  INTO employees
                      employee_id,
                      first_name,
                      last_name,
                      email,
                      hire_date,
                      job_id,
                      department_id
                    VALUES
                      employees_seq.NEXTVAL,
                      first_name,
                      last_name,
                      SUBSTR(first_name,1,1)
                      ||SUBSTR(last_name,1,7)
                      ||'@buongio.com',
                      sysdate,
                      'SA_REP',
                      deptid
         ELSE
            RAISE_APPLICATION_ERROR (-20204, 'Invalid job ID. Try again.');
          END IF;
    END add_employee;
    PROCEDURE init_jobs
    is
    begin
    FOR rec IN
      (SELECT job_id FROM jobs
      LOOP
        valid_jobs(rec.job_id):=true;
      END LOOP;
    END init_jobs;
    function valid_jobid(
        jobid employees.job_id%type)
      return boolean
    is
    BEGIN
    return valid_jobs.exists(jobid);
    EXCEPTION
    WHEN no_data_found THEN
    dbms_output.put_line('no valid');
      RETURN FALSE;
    END valid_jobid ;
    BEGIN
      init_jobs;
    END emp_pkg;

  • ORA-06502: PL/SQL error with dimensions and roles

    Hi everyone,
    When executing a mapping that loads a cube we are always getting that ORA-06502: PL/SQL error character string buffer too small
    The cube contains a number of dimensions, some of them with roles. We've checked that the error appears when we use two different lookup operators to fill dimension atributtes in the cube and its correspondent role. If we map dimension attributes with lookup operator, and the role attributes with constants, the mapping executes without any error. Moreover, even thought it doesnt make any sense, if we map the role dimension attributes with a lookup operator linked to a different dimension, it works too.
    We think that this could be due to attributes names, maybe they are too long, but we have tried to make them shorter and still getting the same error.
    Any ideas of what could be happening?
    Thank you so much in advance.

    The return datatype in a PLSQL function is unconstrained. Which means it does not have a size.
    The size is declared on the receiving end.
    What size variable are you trying to return your value into?
    Here is an example...
    SQL>create or replace function my_func
      2  return varchar2
      3  is
      4  begin
      5    return USER;
      6  end;
      7  /
    Function created.
    SQL>declare
      2    my_string varchar2(30);
      3  begin
      4    my_string := my_func;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL>declare
      2    my_string varchar2(3);
      3  begin
      4    my_string := my_func;
      5  end;
      6  /
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 4

  • ORA-06502: PL/SQL APEX 3.2 Upgrade problem

    We have 2 APEX environments on our 2 servers. Both servers are running Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production.
    One server was running APEX 3.0.0.00.24 (or thereabouts) and was upgraded to 3.2.0.00.27. The other server did not previously have APEX and so 3.2.0.00.27 has been installed as a new version.
    We have a form that is filled in by the users. When they click submit the process adds an entry to a table, and then tries to send an email to our users as a HTML formatted email. The process creates a VARCHAR Variable and then using a cursor creates the text for the the email (including all the HTML tags). Running this process on the original server before the upgrade, but using the formatted email resulted in an ORA-06502: PL/SQL error. Creating an email that was a lot simpler (not html formated and therfore shorter) did actually work correctly.
    I am lead to believe that there was a bug in Apex versions 3.0 that even if a PL/SQL VARCHAR2 variable was defined as 32000 characters it would actually only be able to use/store a lot less than that (1-2000 characters), and any attempt to use more would result in a ORA-06502: PL/SQL error (string buffer too small type message). I cannot seem to access Metalink at the moment so cannot confirm what the actual bug number is. I am also lead to believe that this error was actually addressed and fixed in one of the releases of APEX 3.1, and definitely in APEX 3.2.
    So going with the advice that the issue had been resolved in APEX 3.2, I tried it out in the server with the brand new install. It worked perfectly. I then proceeded to try it in the server that had been upgraded to APEX 3.2.0.00.27. It fails with the same error as before even with the same data as used in the clean install.
    Is there a file / setting / configuration somewhere that has to be changed so the APEX applications can use VARCHAR2 variable with more actual characters?
    Here is a copy of the code being used:
    for c1 in (select DISTINCT OUT_ID, OUT_REQUEST_DATE, OUT_ISSUE, OUT_ETA,
    OUT_KEY_COMMENTS, STATUS_UPDATE_DATE, STATUS_NOTES,
    OUT_EMAIL_TO, P_STATUS, P_SYS, SYS, STATUS,
    ASSIGNED_TO, EMAIL_ADDR, USERNAME, STAT_USERNAME, OUTAGE_LENGTH_BUS_HRS,
    AFFECTED_SYSTEM, SMSLIST, NVL(OUT_BUSINESS_IMPACT,'NOT KNOWN') OUT_BUSINESS_IMPACT,
    OUT_CAUSE_COMMENT, FINAL_CAUSE, FIX,EM.EMAIL
    from HTMLDB_DEV_OPP.VW_OUT_CURRENT_STATUS ST,
    APEX_WORKSPACE_APEX_USERS EM
    where OUT_ID = :P8_OUT_ID
    AND INSTR(':'||ST.EMAIL_ADDR||':',':'||EM.USER_NAME||':') > 0
    ) loop
    if c1.EMAIL is not null then
    l_body_html := '<table align="center" border="0"
    cellpadding="0" cellspacing="0" width="800">
    <tbody>
    <tr>
    <td colspan="3"
    bgcolor="#87b5ed"> 
    Name of section within company here
    </td>
    </tr>
    <tr>
    <td colspan="3"
    style="font-weight: bold; font-size: 28px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"
    bgcolor="#87b5ed">DASS OUTAGE - ' || C1.SYS ||'</td>
    </tr>
    <tr>
    <td colspan="3"
    style="font-size: 12px; color: rgb(255, 255, 255); font-family: Arial,Helvetica,sans-serif;"
    bgcolor="#87b5ed" valign="center">' ||
    TO_CHAR(SYSDATE,'DY DD MON YYYY HH24:MI') || '</td>
    </tr>
    <tr>
    <td bgcolor="#87b5ed" width="50"><br>
    </td>
    <td rowspan="1"
    bgcolor="#ffffff" valign="top" width="400">
    <table
    style="width: 808px; height: 63px;" border="0"
    cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td
    style="background-color: rgb(21, 103, 171); width: 800px; font-weight: bold; color: rgb(255, 255, 255); font-family: Arial,Helvetica,sans-serif;"
    colspan="3"><img alt="" src="cbi_out2_files/spacer.gif" align="middle" height="30" width="20">' || C1.OUT_KEY_COMMENTS ||'</td>
    </tr>
    </tbody>
    </table>
    <table
    style="height: 722px; width: 804px;" align="center"
    border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td style="width: 802px;"
    valign="top">
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>An
    outage has been created in the CBI DASS System. </strong></p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    What is the Outage?</strong><br>'||
    C1.OUT_ISSUE||'<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    What is the current status?</strong><br>'||
    C1.STATUS||'<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    Status update Comments?</strong><br>
    AT '||C1.STATUS_UPDATE_DATE || ' ' ||C1.STAT_USERNAME||' updated the system
    with the following:'||C1.STATUS_NOTES ||'<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    Streams Affected?</strong><br>
    Reported against '||C1.SYS||', also affecting downstream systems ' ||
    C1.AFFECTED_SYSTEM ||'<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    What is the Business Impact?</strong><br>' ||
    C1.OUT_BUSINESS_IMPACT||'<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    What was the cause?</strong><br>' ||
    C1.FINAL_CAUSE||'. ('||C1.OUT_CAUSE_COMMENT||')<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    Has a fix been identified?</strong><br>'||
    C1.FIX||'<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    When did the Outage commence?</strong><br>'||
    C1.OUT_REQUEST_DATE||' (Length in Bus/Hrs '||C1.OUTAGE_LENGTH_BUS_HRS||')<br>
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>Estimated
    Restore Time / Day?</strong><br>'||
    C1.OUT_ETA||'
    </p>
    <p
    style="margin-left: 0px; width: 800px; font-size: 16px; color: rgb(0, 0, 102); font-family: Arial,Helvetica,sans-serif;"><strong>
    Click the link for further info View DASS '||:P8_OUT_ID||
    '</p>
    </td>
    </tr>
    </tbody>
    </table>
    </td>
    <td bgcolor="#87b5ed" width="50"></td>
    </tr>
    <tr>
    <td bgcolor="#87b5ed"><br>
    </td>
    <td bgcolor="#1567ab"><br>
    </td>
    <td bgcolor="#87b5ed"><br>
    </td>
    </tr>
    <tr>
    <td colspan="3"
    bgcolor="#87b5ed"> </td>
    </tr>
    </tbody>
    </table>
    <br>';
    APEX_MAIL.SEND(
    P_TO => c1.EMAIL,
    P_FROM => '"CBI DASS Email"<OUR EMAIL ADDRESS>',
    P_BODY => l_body_html,
    P_BODY_HTML => l_body_html,
    P_SUBJ => 'CBI System / Data Delay Notification '|| c1.OUT_ID || ' (System ' || c1.SYS ||') ');
    end if;
    end loop;
    Thanks
    Russell

    bump ... does anyone have any ideas?
    Thanks Russell

  • Problem with error ORA-06502: PL/SQL: numeric or value error string

    Hi,
    I am running a loop to just spool output data using 'dbms_output.put_line' and I keep getting this error after a few records. I resorted it and it happen at a different interval. Could it have to do with the length of the item I am trying to spool? Thanks.
    ORA-06502: PL/SQL: numeric or value error string

    SD wrote:
    Hi,
    I am running a loop to just spool output data using 'dbms_output.put_line' and I keep getting this error after a few records. I resorted it and it happen at a different interval. Could it have to do with the length of the item I am trying to spool? Thanks.
    ORA-06502: PL/SQL: numeric or value error stringyes, it is a data dependent error.
    Handle:     SD
    Status Level:     Newbie
    Registered:     Nov 21, 2001
    Total Posts:     289
    Total Questions:     189 (183 unresolved)
    why do you waste time here when you rarely get your questions answered?

  • ORA-06502: PL/SQL: numeric or value error: character string buffer too smal

    Hi Guys I am getting error ORA-06502: PL/SQL: numeric or value error: character string buffer too small as it said i thought it would be issue with length of feild but i tried to change is nothihg work i am posing code here if any one can please help me on this
    PROCEDURE REPORT
    p_rpt_from_dt in varchar2,
    p_rpt_to_dt in varchar2,
    p_apvr_id in tc_wkr.tc_row_id%type default NULL,
    p_rpt_type in varchar2 default NULL,
    p_backto_pg in varchar2 default NULL
    IS
    v_rpt_from_dt date := var_to_date(p_rpt_from_dt);
    v_rpt_to_dt date := var_to_date(p_rpt_to_dt);
    v_time_str varchar2(15);
    cursor period_cur
    cp_from_dt date,
    cp_to_dt date
    is
    select beg_dt, end_dt
    from jmcs_wk_tprd
    where beg_dt <= cp_to_dt -- report end date
    and end_dt >= cp_from_dt -- report start date
    BEGIN
    if sys_security('tcsys', 'tc_reports') != 'GRANTED' then
    apps_main.access_denied;
    return;
    end if;
    if lg_debug_fl then
    v_time_str := to_char(lg_sysdate, 'hh:mi:ss a.m.');
    else
    v_time_str := tc_time(lg_sysdate);
    end if;
    /* get the time card time periods applicable to the report */
    lga_tc_strt_dt := lga_null_date;
    for recs in period_cur(v_rpt_from_dt, v_rpt_to_dt) loop
    lga_tc_strt_dt(lga_tc_strt_dt.count+1) := recs.beg_dt;
    lga_tc_end_dt(lga_tc_end_dt.count+1) := recs.end_dt;
    end loop;
    --if p_apvr_id is NULL then
    if p_rpt_type != 'D' then
    tc_reporting.reports_header
    1,
    'Time Card Status Report',
    'for '||dd_mon_yyyy(v_rpt_from_dt)||' through '||dd_mon_yyyy(v_rpt_to_dt)||'<BR>'||
    'Report Date: '||dd_mon_yyyy(lg_sysdate)||' Time: '||v_time_str,
    NULL,
    NULL,
    NULL,
    'javascript:window.close()', /* Backto */
    'alert(''Reminder! Click on logo when you are ready to return to previous page'')'
    end if;
    if p_apvr_id is NULL then
    sub_STATUS_BD_ALPHA (v_rpt_from_dt, v_rpt_to_dt, TRUE, p_rpt_type, p_apvr_id);
    else
    htp.p('<!-- Selected Approver ('||p_apvr_id||') -->');
    sub_STATUS_BD_APVR (v_rpt_from_dt, v_rpt_to_dt, p_rpt_type, p_apvr_id);
    end if;
    htp.p('</body></html>');
    EXCEPTION
    WHEN OTHERS THEN
    error_proc(SQLERRM, SQLCODE, owa_util.get_cgi_env('PATH_INFO'));
    htp.p('Error Code is :'||SQLERRM);
    END REPORT;
    This package in trun call other procedure like below
    PROCEDURE sub_STATUS_BD_ALPHA
    p_rpt_from_dt in date,
    p_rpt_to_dt in date,
    p_display_hdr in boolean,
    p_rpt_type in varchar2 default 'B',
    p_apvr_id in tc_wkr.tc_row_id%type default NULL,
    p_tcs_user_id in tc_wkr.tc_row_id%type default NULL
    IS
    v_time_str varchar2(15);
    v_apvr_id tc_wkr.tc_row_id%type := 0;
    v_a_user_id tc_wkr.tc_row_id%type; -- approver tcs_user_id
    v_cnt integer := 0;
    v_people_cnt integer := 0;
    v_stat_cd varchar2(2000);
    v_display_fl boolean := FALSE;
    /*===========================================================================*/
    cursor people_cur
    cp_from_dt in date,
    cp_to_dt in date
    is
    select
    d_full_nm_lfm as name,
    tc_row_id as tcs_user_id,
    tcw_typ as pay_typ,
    tcw_id as pay_id,
    sys_strt_date as sys_strt_dt,
    sys_end_dt
    from tc_wkr
    where sys_strt_date <= cp_to_dt
    and nvl(sys_end_dt, cp_to_dt) >= cp_from_dt
    order by upper(d_full_nm_lfm);
    /* find the current or the most recent (if no current) approver */
    cursor apvr_cur
    cp_tcs_user_id in tc_wkr.tc_row_id%type
    is
    select
    a.f_tc_apvr_id as fk_tcs_apvr_id,
    w.d_full_nm_lfm as apvr_name,
    w.tcw_typ as apvr_pay_typ,
    w.tcw_id as apvr_pay_id,
    a.strt_dt,
    a.end_dt
    from tc_wkr w, tc_ap_asmt a
    where a.f_tc_wkr_id = cp_tcs_user_id
    and w.tc_row_id = a.f_tc_apvr_id
    order by a.strt_dt desc;
    /* list of existing time cards UNION required time cards */
    cursor tc_cur
    cp_tcs_user_id in tc_wkr.tc_row_id%type, /* who's time cards */
    cp_from_dt in date, /* report period from date */
    cp_to_dt in date /* report period to date */
    is
    select
    stat_cd,
    strt_dt,
    end_dt
    from tc
    where strt_dt <= cp_to_dt
    and end_dt >= cp_from_dt
    and fk_tc_wkrtcw_id = cp_tcs_user_id
    UNION
    select
    'Required' as stat_cd,
    beg_dt as strt_dt,
    end_dt
    from jmcs_wk_tprd
    where beg_dt <= cp_to_dt
    and end_dt >= cp_from_dt
    and beg_dt not in (
    select strt_dt
    from tc
    where strt_dt <= cp_to_dt
    and end_dt >= cp_from_dt
    and fk_tc_wkrtcw_id = cp_tcs_user_id
    order by strt_dt;
    BEGIN
    if lg_debug_fl then
    v_time_str := to_char(lg_sysdate, 'hh:mi:ss a.m.');
    else
    v_time_str := tc_time(lg_sysdate);
    end if;
    if p_apvr_id > 0 then
    lga_report_out := lga_report_out_null;
    v_apvr_id := p_apvr_id;
    lga_apvr := lga_apvr_null;
    select
    d_full_nm_lfm,
    tc_row_id,
    tcw_id,
    tcw_typ
    into
    lga_apvr(1).apvr_name,
    lga_apvr(1).apvr_tcs_id,
    lga_apvr(1).apvr_pay_id,
    lga_apvr(1).apvr_pay_typ
    from tc_wkr
    where tc_row_id = v_apvr_id;
    if lga_apvr(1).apvr_pay_typ != 'S' then
    select decode(bend_empl_fl, 'Y', 'E', 'W')
    into lga_apvr(1).apvr_pay_typ
    from empl
    where empl_id = lga_apvr(1).apvr_pay_id;
    end if;
    end if;
    if p_display_hdr then
    if lga_tc_strt_dt.count > 6 then /* more than 6 time periods (1 month) */
    lga_width(1) := to_char(.15 * lg_page_width_standard);
    lga_width(2) := to_char(.08 * lg_page_width_standard);
    for i in 1..lga_tc_strt_dt.count loop
    lga_width(lga_width.count+1) := to_char(.09 * lg_page_width_standard);
    end loop;
    lg_page_width_standard := to_number(lga_width(1)) + to_number(lga_width(2));
    if nvl(p_apvr_id, 0) = 0 then
    lg_page_width_standard := lg_page_width_standard * 2;
    end if;
    htp.p('<!-- page width = '||lg_page_width_standard||'-->');
    for i in 3..lga_width.count loop
    lg_page_width_standard := lg_page_width_standard + to_number(lga_width(i));
    htp.p('<!-- page width = '||lg_page_width_standard||'-->');
    end loop;
    lg_page_width := to_char(lg_page_width_standard);
    else
    lga_width(1) := '15%';
    lga_width(2) := '8%';
    lga_width(3) := '9%';
    lga_width(4) := '9%';
    lga_width(5) := '9%';
    lga_width(6) := '9%';
    lga_width(7) := '9%';
    lga_width(8) := '9%';
    end if;
    sub_DETAIL_PAGE_HD(p_apvr_id);
    end if;
    /* cursor loop */
    for p in people_cur(p_rpt_from_dt, p_rpt_to_dt) loop
    /* is/was this person assigned to the selected approver for the report period */
    v_display_fl := FALSE;
    if nvl(p_tcs_user_id, 0) > 0 then
    if p_tcs_user_id = p.tcs_user_id then
    htp.p('<br>Selected User');
    v_display_fl := TRUE;
    end if;
    elsif nvl(p_apvr_id, 0) = 0 then
    if nvl(p_apvr_id, 0) = 0 then
    v_display_fl := TRUE;
    elsif p_apvr_id > 0 or p_apvr_id = -1 then
    v_display_fl := fct_ASSIGNED_APVR(p.tcs_user_id, p_apvr_id, p_rpt_from_dt, p_rpt_to_dt);
    end if;
    if v_display_fl then
    v_people_cnt := v_people_cnt + 1;
    lg_tcs_owner_info.USER_ID := p.tcs_user_id;
    lg_tcs_owner_info.PAY_ID := p.pay_id;
    lg_tcs_owner_info.PAY_TYPE := p.pay_typ;
    lg_tcs_owner_info.SYS_STRT_DT := p.sys_strt_dt;
    lg_tcs_owner_info.TERM_DT := p.sys_end_dt;
    if p.pay_typ = 'S' then
    begin
    select wrk_hire_dt
    into lg_tcs_owner_info.hire_dt
    from subcntr
    where sub_id = p.pay_id;
    exception
    when no_data_found then
    tc_debug.html_message('subcntr.pay_id('||p.pay_id||')');
    end;
    else
    select
    wrk_hire_dt,
    decode(bend_empl_fl, 'Y', 'E', 'W')
    into
    lg_tcs_owner_info.hire_dt,
    lg_tcs_owner_info.pay_type
    from empl
    where empl_id = lg_tcs_owner_info.PAY_ID;
    end if;
    if lga_report_out.count = 0 then
    lga_report_out(lga_report_out.count+1) := '<table border="1" cellpadding="3" width="'||lg_page_width||'">';
    end if;
    if mod(v_people_cnt,2) = 1 then
    lga_report_out(lga_report_out.count+1) := ('<tr bgcolor="'||lg_odd_bgcolor||'">');
    else
    lga_report_out(lga_report_out.count+1) := ('<tr bgcolor="'||lg_even_bgcolor||'">');
    end if;
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>'||p.name||'</font></td >');
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>'||p.pay_typ||'-'||lpad(p.pay_id,4,'0')||'</font></td >');
    if nvl(p_apvr_id, 0) > 0 then /* Single Approver */
    /* need approver ID for time card "status" */
    lga_apvr := lga_apvr_null; /* clear the approver id array */
    lga_apvr(1).apvr_tcs_id := p_apvr_id;
    elsif nvl(p_apvr_id, 0) = 0 then /* ALL Approvers */
    lga_apvr := lga_apvr_null; /* clear the approver id array */
    v_cnt := 0;
    for ap in apvr_cur (p.tcs_user_id) loop
    if v_cnt = 0 then
    /* most recent approver may not be the applicable approver */
    v_cnt := 1;
    lga_apvr(v_cnt).apvr_name := ap.apvr_name; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_tcs_id := ap.fk_tcs_apvr_id; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_pay_id := ap.apvr_pay_id; -- identify multiple approvers for the "status"
    v_apvr_id := ap.fk_tcs_apvr_id;
    if ap.apvr_pay_typ = 'S' then
    lga_apvr(v_cnt).apvr_pay_typ := ap.apvr_pay_typ; -- identify multiple approvers for the "status"
    else
    select decode(bend_empl_fl, 'Y', 'E', 'W')
    into lga_apvr(1).apvr_pay_typ
    from empl
    where empl_id = lga_apvr(1).apvr_pay_id;
    end if;
    end if;
    if ap.strt_dt <= p_rpt_to_dt and nvl(ap.end_dt, p_rpt_to_dt) >= p_rpt_from_dt then
    /* approver record */
    lg_tcs_owner_info.APVR_ID := ap.fk_tcs_apvr_id;
    lg_tcs_owner_info.APVR_STRT_DT := ap.strt_dt;
    lg_tcs_owner_info.APVR_END_DT := ap.end_dt;
    don't enter same approver name multiple times
    when same approver has been assigned more than once
    Example: approver1, approver_2, approver_1 (change back to approver 1)
    for i in 1..lga_apvr.count loop
    v_apvr_id := ap.fk_tcs_apvr_id;
    if lga_apvr(i).apvr_tcs_id = ap.fk_tcs_apvr_id then
    /* don't add again */
    v_apvr_id := NULL;
    exit;
    end if;
    end loop;
    if v_apvr_id is not NULL then
    v_cnt := v_cnt + 1;
    lga_apvr(v_cnt).apvr_name := ap.apvr_name; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_tcs_id := ap.fk_tcs_apvr_id; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_pay_id := ap.apvr_pay_id; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_pay_typ := ap.apvr_pay_typ; -- identify multiple approvers for the "status"
    end if;
    end if;
    end loop;
    /* list approver pay IDs */
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>');
    if lga_apvr.count = 0 then
    lga_report_out(lga_report_out.count+1) := 'Approver Unassigned';
    else
    for i in 1..lga_apvr.count loop
    if i > 1 then
    lga_report_out(lga_report_out.count+1) := '<br>';
    end if;
    lga_report_out(lga_report_out.count+1) := (lga_apvr(i).apvr_name);
    end loop;
    end if;
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>');
    if lga_apvr.count = 0 then
    lga_report_out(lga_report_out.count+1) := 'N/A';
    else
    for i in 1..lga_apvr.count loop
    if i > 1 then
    lga_report_out(lga_report_out.count+1) := '<br>';
    end if;
    lga_report_out(lga_report_out.count+1) := (lga_apvr(i).apvr_pay_typ)||'-'||lpad(lga_apvr(i).apvr_pay_id,4,'0');
    end loop;
    end if;
    lga_report_out(lga_report_out.count+1) := ('</font></td >');
    end if;
    for t in tc_cur(p.tcs_user_id, p_rpt_from_dt, p_rpt_to_dt) loop
    htp.p('<! '||t.strt_dt||', '||t.end_dt||', '||t.stat_cd||' -->');
    --lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>');
    --lga_report_out(lga_report_out.count+1) := (t.stat_cd);
    --lga_report_out(lga_report_out.count+1) := ('</font></td >');
    /* has the selected approver has completed processing */
    if p_apvr_id > 0
    and v_apvr_id = p_apvr_id
    and v_a_user_id != p_apvr_id
    then
    exit;
    end if;
    for ap in apvr_cur (p.tcs_user_id) loop
    if apvr_cur%rowcount = 1 then
    /* most recent approver assigned */
    lg_tcs_owner_info.apvr_id := ap.fk_tcs_apvr_id;
    end if;
    if ap.strt_dt <= t.end_dt and nvl(ap.end_dt, t.end_dt) >= t.strt_dt then
    /* approver assigned during time card period */
    lg_tcs_owner_info.apvr_id := ap.fk_tcs_apvr_id;
    exit;
    end if;
    end loop;
    lg_tc_status.strt_dt := t.strt_dt;
    lg_tc_status.end_dt := t.end_dt;
    lg_tc_status.stat_cd := t.stat_cd;
    v_stat_cd := fct_TC_STATUS(nvl(p_apvr_id, 0));
    lga_report_out(lga_report_out.count+1) := ('<td align="center" valign="top" bgcolor="'||lg_tc_status.bg_color||'">');
    lga_report_out(lga_report_out.count+1) := ('<font size=-2 color='||lg_tc_status.font_color||'>');
    lga_report_out(lga_report_out.count+1) := v_stat_cd;
    lga_report_out(lga_report_out.count+1) := ('</font></td >');
    end loop;
    lga_report_out(lga_report_out.count+1) := '</tr>';
    end if; /* v_display_fl */
    end loop;
    if p_rpt_type in ('B', 'S') then
    lg_page_cnt := lg_page_cnt + 1;
    sub_DISPLAY_STATUS_SUMMARY;
    end if;
    if lga_report_out.count > 0 then
    lga_report_out(lga_report_out.count+1) := '</table>';
    end if;
    if lga_report_out.count > 0 then
    if p_rpt_type = 'B' or p_apvr_id > 0 then
    if p_display_hdr then
    if lg_page_cnt > 0 then
    if p_apvr_id > 0 then /* selected individual approver */
    htp.p('</table>');
    end if;
    htp.p('<br style="page-break-after:always">');
                        htp.p('<!-- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -->');
                        htp.p('<!-- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -->');
    end if;
    lg_page_cnt := lg_page_cnt + 1;
    tc_reporting.reports_header
    1,
    'Time Card Status Report',
    'for '||dd_mon_yyyy(p_rpt_from_dt)||' through '||dd_mon_yyyy(p_rpt_to_dt)||'<BR>'||
    'Report Date: '||dd_mon_yyyy(lg_sysdate)||' Time: '||v_time_str,
    NULL,
    NULL,
    NULL,
    NULL, -- p_backto_pg, /* Backto */
    'focus()',
    lg_page_cnt
    end if;
    end if;
    if p_rpt_type in ('B', 'D') then
    for i in 1..lga_report_out.count loop
    htp.p(lga_report_out(i));
    end loop;
    end if;
    end if;
    END sub_STATUS_BD_ALPHA;
    Some veriable
    type report_tc_rec is record
    tc_owner_name tc_wkr.d_full_nm_lfm%type,
    o_user_id tc_wkr.tc_row_id%type,
    o_pay_id varchar2(10),
    o_sys_strt_dt date,
    o_sys_end_dt date,
    tc_apvr_name tc_wkr.d_full_nm_lfm%type,
    a_pay_id varchar2(10),
    a_user_id tc_wkr.tc_row_id%type,
    tc_strt_dt date,
    tc_end_dt date,
    tc_stat_cd varchar2(50),
    ap_strt_dt date,
    ap_end_dt date
    /* time card owner information */
    TYPE tcs_owner_info_rec IS RECORD
    USER_ID tc_wkr.tc_row_id%type,
    PAY_ID tc_wkr.tcw_id%type,
    PAY_TYPE tc_wkr.tcw_typ%type,
    HIRE_DT date,
    SYS_STRT_DT date,
    TERM_DT date,
    APVR_ID tc_wkr.tc_row_id%type,
    APVR_STRT_DT date,
    APVR_END_DT date
    /* status code determines report cell font and background colors */
    TYPE tc_status_rec IS RECORD
    STRT_DT date,
    END_DT date,
    STAT_CD tc.stat_cd%type,
    FONT_COLOR varchar2(16),
    BG_COLOR varchar2(16)
    /* count of all time card status for report summary */
    TYPE tc_status_summary_rec IS RECORD
    APPROVED_CNT integer := 0,
    REJECTED_CNT integer := 0,
    SUBMITTED_CNT integer := 0,
    POSTED_CNT integer := 0,
    VERIFIED_CNT integer := 0,
    OPEN_CNT integer := 0,
    NEW_CNT integer := 0,
    REQUIRED_CNT integer := 0,
    TOTAL_CNT integer := 0
    /* determine multiple approvers for individual for selected report period */
    TYPE apvr_rec IS RECORD
    apvr_name tc_wkr.d_full_nm_lfm%type,
    apvr_tcs_id tc_wkr.tc_row_id%type,
    apvr_pay_id tc_wkr.tcw_id%type,
    apvr_pay_typ tc_wkr.tcw_typ%type
    TYPE apvr_id_array_table IS TABLE OF apvr_rec
    index by binary_integer;
    type output_array is table of varchar2(1000)
    index by binary_integer;
    type date_array is table of date
    index by binary_integer;
    type status_array is table of varchar2(1000)
    index by binary_integer;
    type apvr_array is table of number(8)
    index by binary_integer;
    lga_report_out output_array; /* array of HTML code to be output to browser */
    lga_report_out_null output_array; /* null array of HTML code */
    lga_tc_status status_array;
    lga_null_status status_array;
    lga_tc_strt_dt date_array;
    lga_tc_end_dt date_array;
    lga_tc_disp date_array; /* start dates of displayed TC for selected user */
    lga_null_date date_array; /* null array used to clear other date arrays */
    /* LOCAL GLOBAL VARIABLES */
    lg_tcs_owner_info tcs_owner_info_rec; /* time card owner information */
    lg_tc_status tc_status_rec; /* time card status information */
    lg_tc_status_summary tc_status_summary_rec; /* time card count by status */
    lg_tc_rec report_tc_rec; /* time card */
    lga_apvr apvr_id_array_table; /* array of approver Names and Payroll IDs */
    lga_apvr_null apvr_id_array_table; /* clear the lga_apvr array for each user */
    lg_sysdate date := sysdate;
    lg_debug_fl boolean := FALSE;
    lg_debug_owner_id tc_wkr.tc_row_id%type := 9905;
    lg_debug_apvr_id tc_wkr.tc_row_id%type := 1000;
    The chnages i have done its in bold
    Please Advice
    Thanks
    Edited by: Purvik on Aug 25, 2009 11:59 AM

    There is not a chance in the world, especially not knowing column definitions that I, and I suspect most anyone else, is going to wade through this much unformated code looking for an error you couldn't bother to copy in full.
    Either tell us, specifically, the line on which the error is occurring or, better yet, start whacking stuff out of your code until you find the offending definition. That is certainly what I would do. Commenting out sections is a marvelous way to quickly find an issue.
    Before you post again please read the FAQ. It will explain to you how to properly post and use the tags.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Report error: ORA-06502: PL/SQL: numeric or value error: character string b

    I have a form which uses a customer form/report, drop downs etc..
    the debug shows it running this statement
    ...Execute Statement: begin begin SELECT distinct initcap(RTRIM (LTRIM (e.surname, ' *0123456789-/:.?,'), ' *0123456789-/:.?,') || ', ' || RTRIM (LTRIM (e.first_name, ' *0123456789-/:.?,'), ' *0123456789-/:.?,' )) empname, e.ID bulk collect into wwv_flow_utilities.g_display,wwv_flow_utilities.g_value FROM dms.dms_employees@dmsprd e, dms.dms_employee_contracts@dmsprd ec WHERE e.ID = ec.emp_id and e.surname like '%%' AND :p75_date BETWEEN ec.start_date AND NVL (ec.end_date, :p75_date) AND e.brh_id = 3654 ORDER BY 1; end; end;
    Then says
    "report error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small"
    Any Ideas?
    Thanks
    Dean

    Denes Kubicek wrote:
    A select list is limited in size. I am not sure what the limit is but that is definitelly the case.The maximum size for the HTML generated for a select list is 32K.
    86 options sounds on the low side to be hitting that limit, but there are other concerns to this as well. Scrolling through hundreds/thousands of options in a select list is a pain for users, and huge select lists produce bloated pages that impact load times and network bandwidth. That list of around 200 countries you find on many sites is about the sensible maximum length for a select list.
    You should use popups.Indeed.

  • Report error:ORA-06502: PL/SQL: numeric or value error: character to number

    The oracle application express environment is created by installing the HTTP Server on the windows server and the application express 3.2.1 components on the 11.1.0.7 oracle database on UNIX. The installation is successfully and have not seen any issues during the installation. After completing all the steps, when tried to login and click the application builder or workspace components, I see the error message
    report error:ORA-06502: PL/SQL: numeric or value error: character to number.
    This error message is seen on most of the pages when trying to accessed and not able to understand the reasons behind it. Its a brand new environment setup and not even presented to developers to test it.
    Below error message is always seen when trying to access most of the components like application builder, schema comparison and some other tabs. Please advice
    report error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Edited by: user589320 on Jun 9, 2011 5:17 PM

    I think its better you use APEX 4.x version ratherthan using old version.
    You will get more features and some bug fixes and also it's easy for you to get some help when you need.
    * If this answer is helpfull or correct then please mark it and grant the points.

  • Report error:ORA-06502: PL/SQL: numeric or value error: character string bu

    We face the above error in HTMLDB (APEX) application Ver 3.1.0. This occurs when we try to display more number of rows/records in drop-down list (LOV in tabular forms). We are able to display 200 records in LOV. When the list of records exceeds 230, we face the below error
    report error:ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    the values listed in LOV are from tables (one of the columns in table)
    Could anyone give us a solution?

    Hi
    As you are using a tabular form, you could actually do the following:
    1 - In the tabular form column's attributes, set the following:
    Display as: Select List (query based on LOV)
    Display extra values: Yes
    List of values definition: SELECT null d, null r FROM DUAL
    2 - Add a new page item and set it to generate your select list
    3 - Create an HTML region with no template and use the following for its source:
    &lt;script type="text/javascript"&gt;
    function loadList(c, l)
    var s = document.getElementsByName(c);
    var lItem = document.getElementById(l);
    var lLength = lItem.options.length;
    var k;
    var j;
    var x = lItem.innerHTML;
    var v;
    var o;
    var z;
    for (k = 0; k &lt; s.length; k++)
    z = s[k];
    v = z.value;
    z.options.length = 0;
    for (j = 0; j &lt; lLength; j++)
    o = new Option()
    o.value = lItem[j].value;
    o.text = lItem[j].text;
    z.options[j] = o;
    z.value = v;
    if (z.selectedIndex == -1)
    z.selectedIndex = 0;
    loadList("f05", "P1_MGR");
    &lt;/script&gt;
    (Change "f05" and "P1_MGR" as appropriate to your column and your new page item respectively)
    Now, when you load the page, the select list contains a null entry plus the entry already on the database. The javascript kicks in automatically, loops through every entry in the "f05" column, copies the existing value, replaces the select list with the new page item version and sets its value to the copied value.
    Your new page item could be in a DIV tag that has a style of "display:none" to hide it from view.
    Andy

  • Report error: ORA-06502: PL/SQL: numeric or value error: NULL index table k

    Hi everybody,
    I have two Distinct Databases on two distinct servers. (Oracle Ent. Release 10.2.0.3.0 on AIX 5.3). After I install the latest patch last week, One of the APEX installation has some problems on Home>Application Builder Page. The error message is very random and
    report error:
    ORA-06502: PL/SQL: numeric or value error: NULL index table key value.
    When i change the view (details to icons), everything goes to normal. This error message is reflected some of the pages (report region) of some of my applications randomly. When it appears in a report region, i deselect the order method of the region, the result is normal.
    But the other APEX application on the other instance has no problem. It is a bug? or Should i re-install the APEX instance?
    Thank you for your interest?
    Gökhan ÇATALKAYA

    No, but we have a reproducible test case now so we're working on it. See ORA-06502: PL/SQL: numeric or value error: NULL index table key value
    Scott

  • REP-1401: 'cf_10formula': Fatal PL/SQL error occurred. ORA-06502: PL/SQL: numeric or value error

    Hi Team,
    I am running one conc programme.
    After running I am getting below  error. I checked the issue on metalink  and other, seems that it is an size related issue. I have increased the size of formula columns and placeholdder too.
    But still getting issue.
    My requirement is to get comma seperated values using SQL query itself. Neither i wanted to create layout of the report , since it is a XML publisher report and nor  I am including it on RTF template.
    I want the CF_10 formula column to be populated with comma seperated values.
    MSG-00187: From Date 01-Sep-2014
    REP-1401: 'cf_10formula': Fatal PL/SQL error occurred.
    ORA-06502: PL/SQL: numeric or value error
    And Here is my code for CF_10
    function CF_10Formula return Number is
    begin
       SELECT NVL(TO_CHAR(sum(Amount),'99,99,99,999'),0) into :CP_5 --NVL(ROUND(sum(Amount)),0) into :CP_5
    --  xxhw_Coll_cat(category)     "Intercat  Catg"
    FROM hhxw_Region_col_v
    WHERE Category IN ('Intercompany - CATV')
    AND trunc(gl_date) BETWEEN TO_DATE(:P_FROM_DATE, 'DD/MM/RRRR') AND TO_DATE(:P_TO_DATE, 'DD/MM/RRRR');
    RETURN ROUND(:CP_5);
    end;
    Anyone please suggest me.
    Regards,
    Sachin

    Hi,
    1)Why are you selecting the value into a report item? Select into a local variable and return that
    RETURN :CP_5 --> This one!!
    2)And you should avoid applying functions to DB columns in where clauses wherever possible, so oracle can use indexes on them if applicable:
    AND gl_date >= To_date(:P_FROM_DATE, 'DD/MM/RRRR')
    AND gl_date < To_date( :P_TO_DATE, 'DD/MM/RRRR') + 1;
    I think you are taking 2 column in the Layout CF_10 and CP_5 right? if so, then use below Query.
    FUNCTION cf_10formula
      RETURN NUMBER
    IS
      v_amount NUMBER:null;
    IS
    BEGIN
      BEGIN
        SELECT nvl(round(SUM(amount)), 0)
        INTO   v_amount --> Retruns the value for CF_10 column
        FROM   hhxw_region_col_v
        WHERE  category IN ( 'Intercompany - CATV' )
        AND    gl_date >= to_date(:P_FROM_DATE, 'DD/MM/RRRR')
        AND    gl_date < to_date( :P_TO_DATE, 'DD/MM/RRRR') + 1;
        :CP_5 := nvl(trunc(v_amount),0); --> Retruns the value for CP_5 column
      EXCEPTION
      WHEN OTHERS THEN
        v_amount := 0;
        srw.message(1003,'Error in Getting  :' ||p_from_date);
      END;
    END;
    And
    If you've got a number function returning into a number field then all you should need to do to make the comma appear is to change the number format mask in field.
    From 40000 to 40,000

  • SQL Report query ORA-06502: PL/SQL: numeric or value error: character strin

    Hello,
    I have saved below query in the sql scripts, which executes good under SQL Developer,
    select     "RVV"."RLNUM" as "RLNUM",
         "GVREB"."RLNUM" as "RLNUM",
         "TVV"."RLNUM" as "RLNUM_1",
         "Regulation"."CODE" as "CODE",
         "Regulation"."NAAM" as "NAAM",
         "GVREB"."BRONCODE" as "BRONCODE",
         sum(RVV.RVV_MODULATIE) as "RVV_MODULATIE",
         sum(RVV.RVV_EXTRA_MODUL) as "RVV_EXTRA_MODUL",
         sum(GVREB.PMB) as "PMB",
         sum(GVREB.VVM) as "VVM",
         sum(GVREB.VVEM) as "VVEM",
         "GVREB"."STATUS" as "STATUS",
         sum(TVV.VVM) as "VVM",
         sum(TVV.VVEM) as "VVEM",
         "Regulation"."version" as "version",
         "TVV"."Appyear" as "Appyear"
    from     "GVREB" "GVREB",
         "RVV" "RVV",
         "TVV" "TVV",
         "Regulation" "Regulation"
    where      "RVV"."RLNUM" = :P17_Relationnum
    and     "GVREB"."RLNUM" = "RVV"."RLNUM"
    and     "TVV"."RLNUM" = "GVREB"."RLNUM"
    and     "GVREB"."CODE" = "TVV"."RegulationSCODE"
    and     "Regulation"."CODE" = "GVREB"."CODE"
    and     "GVREB"."STATUS" = 'VWT'
    and     "TVV"."Appyear" = 2009
    group by RVV.RLNUM, GVREB.RLNUM, TVV.RLNUM, Regulation.CODE, Regulation.NAAM, GVREB.BRONCODE, GVREB.STATUS, Regulation.version, TVV.Appyear
    order by Regulation.version ASC
    however when tried to put in the region -> query builder it gives below error,
    italics ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Return to application.+italics+
    Kindly suggest me work around this error.
    Cheers,
    G1R15|-|
    Edited by: G on Jul 11, 2010 10:03 PM

    Hi,
    I was able to resolve the issue. I changed it to = To_Number while assigning.
    and for other issue, earlier I choose "Select List" for drop down. I changed this to "Select list with Submit". for the issue of "depending on this values in the report should get change"
    Thanks for your support,
    Girish

  • PL/SQL function body returning SQL query - ORA-06502: PL/SQL: numeric or value error

    I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option.  The SQL query generated will possibly be over 32K.  When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated.  I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL.  I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL.  Our environment is on 11gR2 and using ApEx 4.2.1.  I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using.  Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
    As a test, I created a page on apex.oracle.com with a report region with the following source:
    declare
      l_stub varchar2(25) := 'select * from sys.dual ';
      l_sql  clob := l_stub || 'union all ';
      br     number(3) := 33;
    begin
      while length ( l_sql ) < 34000 loop
        l_sql := l_sql || l_stub || 'union all ';
      end loop;
      l_sql := l_sql || l_stub;
      for i in 1 .. ceil ( length ( l_sql ) / br ) loop
        dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
      end loop;
      return l_sql;
    end;
    The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K.  When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed.  When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
    I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g.  Thoughts?
    Shane.

    What setting do you use in your report properties - especially in Type and in Region Source?
    If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
    According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
    declare
    mycond varchar2(4000);
    begin
    if :P1_REPORT_SEARCH is not null THEN
    mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
    end if;
    return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
    end;
    And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
    For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
    (You would than need to change the code of your function accordingly).
    If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query.

  • Ora-06502 pl/sql numeric or value error in Report Query in oracle apex

    Hello all,
    I need your help...
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    I am using bi publisher to generate PDF reports in oracle apex.
    We were using APEX 4.0 and migrated to 4.2 just a week ago.
    Now we have apex 4.2.
    When I try to Create report query,
    Shared Components >> Report Queries then create.
    and test a report in a create wizard I am getting a error "ORA-06502: PL/SQL: numeric or value error: character string buffer too small".
    I have also applied a patch "16760897".
    This issue is because of number of columns in a query is more then 26.
    If I run a report with 26 or less number of columns then the is working fine, otherwise getting this error.
    My before migration report queries working perfectly even now, but not new queries.
    This issue is also in apex.oracle.com.
    You can see
    Not working  - http://apex.oracle.com/pls/apex/f?p=619:4
    Working - http://apex.oracle.com/pls/apex/f?p=619:2:
    Please give a solution.
    Thanks you.

    check the DB version compatibility with apex 4 or your DB version to apex 4.0 support for upgrade!
    Oracle Application Express Installation Requirements for 4.0

  • Ora-06502:pl/sql and ora-06512 at sys.owa_util errors

    Greetings -
    I have just installed APEX 2.2 in my 9.2.0.7 database and am going through the exercises in the "2 Day+ Application Express Developer's Guide." I was making good progress, until I got to Chapter 5, How to Control Form Layout. I created the script "ht_emp", as instructed. Everything in the script works, except for the "create or replace trigger bi_ht_emp" part. It fails with the following errors:
    ORA-06502: PL/SQL: numeric or value error ORA-06512: at "SYS.OWA_UTIL", lone 328 ORA-06512: at "SYS.HTP", line 862 ORA-06512: at "SYS.HTP", line 977 ORA-06512: at "SYS.HTP", line 995 ORA-06512: at "FLOWS_020200.WWV_FLOW_SW_API", line 428 ORA-01003: no statement parsed. I have confirmed that nls_length_semantics = BYTE
    Any suggestions?
    Thanks in advance - Gail

    Scott -
    Here's the part of the script that chokes --
    CREATE OR REPLACE TRIGGER bi_ht_emp
    BEFORE INSERT ON ht_emp
    FOR EACH ROW
    BEGIN
    SELECT ht_emp_seq.nextval
    INTO :new.emp_id
    FROM DUAL;
    :new.rec_create_date := SYSDATE;
    END;
    Thanks fro helping -
    Gail

Maybe you are looking for

  • How to print all the pages in wad

    HI i am having a report with 3000 records when opened in wad, but when we print the Report, it is giving us records(60) on only first page, how do we print all the 3000 records from all the pages by clciking on print only once. Thank You, Kris.

  • OS authentication in Oracle 10g via jdbc:oracle:oci

    I'm very much a newbie to Java / JDBC and I am trying, but failing, to connect with the database using OS authentication via jdbc, and hoping someone may help. My questions are: 1. Is OS authentication supported for jdbc:oracle:oci with Oracle 10g ?

  • I have a state space model of a complex system. can anyone help me for implementi​ng MPC and e-MPC control for the same?????

    Hi everyone. I am new to the forums, so let me be as mprecise as possible. i know the basic functionalities of Labview with MPC block etc. However, i dont know how to go ahead with implementing MPC control for a system whose state space model i posse

  • Wrong itunes account

    I have several devices, and without thinking about it, set each up on different iTunes accounts.  When setting up my iMatch service, I did it from my original iMac, which uses my Yahoo Mail address for my iTunes account.  Now that I want to see my pl

  • BIG PROBLEM ps3 overheating

    Hey I'm jay I've have recently came across a lot of problems with my ps3 it heats up really fast but there's no dust and its in an open area, it gets hot enough to get me worried plus no heat signs come up it just freezes once its too hot. it freezes