Numeric or value error without size

Is it possible to call SP or function with OUT VARCHAR 2 parameter without submitting size throught ODP.NET ?
If I not submit size, i have the error ORA-06502: Numeric or Value error.
Thank you

I have found that VARCHAR2 parameters always needed a size. This was the case in previous versions of database connectivity as well. Not sure why, maybe someone can explain why this is needed. I'd like to know as well.
-John

Similar Messages

  • Procedure varchar2 parameter size limit? ORA-6502 Numeric or value error

    Hi ALL,
    I am trying to create out parameters in a Procedure. This procedure will be called by 4 other Procedures.
    PROCEDURE create_serv_conf_attn_cc_email
    ( v_pdf_or_text varchar2,
    v_trip_number number ,
    v_display_attn_for_allmodes out varchar2,
    v_display_cc_for_allmodes out varchar2,
    v_multi_email_addresses out varchar2,
    v_multi_copy_email_addresses out varchar2
    When I call that procedure in another Procedure I am getting following error, which is caused by one of the out parameter being more than 255 characters.
    I found that out via dbms_output.put_line(ing) one of the out parameter as I increased its size.
    ORA-06502: PL/SQL: numeric or value error
    I thought there was no size limit on any parameters passed to a Procedure.
    Any one know of this limit of 255 characters on varchar2 Procedure parameters? Is there a work around keeping the same logic?
    If not I will have to take those parameters out and resort to some global varchar2s which I do not like.
    Thanks,
    Suresh Bhat

    I assume one of the variables you have declared is not large enough for it's assignment.
    Here's an example.
    ME_XE?create or replace procedure test_size(plarge in out varchar2 )
      2  is
      3  begin
      4     plarge := rpad('a', 32000, 'a');
      5  end;
      6  /
    SP2-0804: Procedure created with compilation warnings
    Elapsed: 00:00:00.03
    ME_XE?
    ME_XE?declare
      2     my_var   varchar2(32767);
      3  begin
      4     test_size(my_var);
      5     dbms_output.put_line(length(my_var));
      6  end;
      7  /
    32000
    PL/SQL procedure successfully completed.
    --NOTE here how the declared variable is 500 characters, but the procedure will try to assign it over 32,000 characters...no dice
    Elapsed: 00:00:00.00
    ME_XE?
    ME_XE?declare
      2     my_var   varchar2(500);
      3  begin
      4     test_size(my_var);
      5     dbms_output.put_line(length(my_var));
      6  end;
      7  /
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "TUBBY.TEST_SIZE", line 4
    ORA-06512: at line 4
    Elapsed: 00:00:00.04Edited by: Tubby on Oct 22, 2008 12:47 PM

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

  • 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

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

  • Numeric or value error Line 410???  appending to lob

    line 410 is marked with line of '%%%%%%%%%%%%%%%%%%%%%'
    This script is designed to profile data in a set of table by generating sql and running it with an execute immediate. It works by generating a set of code for each datatype and then executing the code twice for each table. Once for the summary profile and once for the detail profile. I've been starting at it awhile and can't figure out what the error means??? Thanks in advance!
    set serveroutput on size 1000000
    set feedback off
    SET ECHO OFF
    declare
    c clob;
    t varchar2(2000);
    e varchar2(2000);
    cursor c1 is select distinct owner,table_name from all_tab_columns
    where table_name in ('PS_F_AP_AGING'
    ,'PS_F_AP_TRAN'
    ,'PS_F_VCHR_MTCH_EXP'
    ,'PS_F_APAR_NETTING'
    ,'PS_F_AR_AGING'
    ,'PS_F_AR_ACCOUNT_LN'
    ,'PS_F_AR_DSO'
    ,'PS_F_AR_TRAN'
    ,'PS_F_ASGN'
    ,'PS_F_CA_AMD'
    ,'PS_F_CA_DTL_DIST'
    ,'PS_F_CA_DTL_TRANS'
    ,'PS_F_CA_REV_RECOGN'
    ,'PS_F_EXP_DTL_DIST'
    ,'PS_F_GM_AWARD'
    ,'PS_F_GM_PRJ_TRAN'
    ,'PS_F_GM_PRP_AWD'
    ,'PS_F_PRJ_AC_CUR'
    ,'PS_F_PRJ_AC_PRDC'
    ,'PS_F_PRJ_CHNG'
    ,'PS_F_PRJ_CUR'
    ,'PS_F_PRJ_PRDC'
    ,'PS_F_PRJ_TRAN'
    ,'PS_F_PRP_VER_TRANS'
    ,'PS_F_RSRC_RT'
    ,'PS_F_INV_CYCLE_CNT'
    ,'PS_F_INV_LDGR'
    ,'PS_F_INV_TRANS'
    ,'PS_F_PHYSICAL_INV'
    ,'PS_F_BEGIN_BAL'
    ,'PS_F_JOURNAL'
    ,'PS_F_KK_ACTIVITY'
    ,'PS_F_KK_BALANCES'
    ,'PS_F_KK_BUD_ASSOC'
    ,'PS_F_KK_ENCUMBRAN'
    ,'PS_F_KK_EXCEPTION'
    ,'PS_F_KK_JOURNAL'
    ,'PS_F_KK_LEDGER'
    ,'PS_F_KK_OVERRIDES'
    ,'PS_F_KK_TRANS_LOG'
    ,'PS_F_LEDGER'
    ,'PS_F_MTCH_ANLYS'
    ,'PS_F_PO_DIST'
    ,'PS_F_PO_LINE'
    ,'PS_F_PO_SHIP_RCPT'
    ,'PS_F_PROC_CTLT'
    ,'PS_F_REQN'
    ,'PS_F_REQN_ANLYSIS'
    ,'PS_F_RTV'
    ,'PS_F_RTV_DIST'
    ,'PS_F_SCP_CAPACITY'
    ,'PS_F_SCP_INVENTORY'
    ,'PS_F_SCP_PRODN'
    ,'PS_F_SCP_PURCHASNG'
    ,'PS_F_SCP_SLS_FCST'
    ,'PS_F_SCP_TRANSFERS'
    ,'PS_F_SCPSLS_ACTUAL'
    ,'PS_F_VCHR'
    ,'PS_F_VCHR_DIST_LN'
    ,'PS_F_VCHR_LN'
    /*,'PS_D_ACCOUNT'
    ,'PS_D_ACTGRY_AR_VW'
    ,'PS_D_AGING_CTGRY'
    ,'PS_D_ALTACCT'
    ,'PS_D_ANLYS_TYPE'
    ,'PS_D_AP_DOC_TYPE'
    ,'PS_D_AP_PTR_STAT'
    ,'PS_D_AP_PTR_TYPE'
    ,'PS_D_AP_PYMNT_TRMS'
    ,'PS_D_AP_VTR_STAT'
    ,'PS_D_AP_VTR_TYPE'
    ,'PS_D_APPOST_STATUS'
    ,'PS_D_AR_DOC_TYPE'
    ,'PS_D_AR_ITR_STAT'
    ,'PS_D_AR_ITR_TYPE'
    ,'PS_D_AR_PTR_STAT'
    ,'PS_D_AR_PTR_TYPE'
    ,'PS_D_ASGN'
    ,'PS_D_ASGN_STAT'
    ,'PS_D_BANK_ACCT'
    ,'PS_D_BOOK_CODE'
    ,'PS_D_BU_LED_GRP'
    ,'PS_D_BUCKET'
    ,'PS_D_BUDGET_REF'
    ,'PS_D_BUSINESS_UNIT'
    ,'PS_D_BUYER'
    ,'PS_D_CA'
    ,'PS_D_CA_AMD_RSN'
    ,'PS_D_CA_AMD_TYPE'
    ,'PS_D_CA_DTL'
    ,'PS_D_CA_JNK'
    ,'PS_D_CARRIER'
    ,'PS_D_CHANNEL'
    ,'PS_D_CHARTFIELD1'
    ,'PS_D_CHARTFIELD2'
    ,'PS_D_CHARTFIELD3'
    ,'PS_D_CLASS_FIELD'
    ,'PS_D_CNCL_STATUS'
    ,'PS_D_COLLECT_STAT'
    ,'PS_D_COMP_STATUS'
    ,'PS_D_CUST_ORG'
    ,'PS_D_CUSTOMER'
    ,'PS_D_DAY'
    ,'PS_D_DEDUCT_STAT'
    ,'PS_D_DEPT'
    ,'PS_D_DET_BUDGET'
    ,'PS_D_DET_PERIOD'
    ,'PS_D_DISPUTE_STAT'
    ,'PS_D_DIST_ACCT'
    ,'PS_D_DLVRY_STATUS'
    ,'PS_D_DT_PATTERN'
    ,'PS_D_ENTRY_RSTYP'
    ,'PS_D_EX_LOCATION'
    ,'PS_D_EXP_LN'
    ,'PS_D_EXP_RPT'
    ,'PS_D_FUND'
    ,'PS_D_GL_ADJ_TYPE'
    ,'PS_D_GM_AWARD'
    ,'PS_D_GM_INST'
    ,'PS_D_GM_PI'
    ,'PS_D_GM_PROP_PROJ'
    ,'PS_D_GM_PRP'
    ,'PS_D_GM_SPONSOR'
    ,'PS_D_INV_ITEM'
    ,'PS_D_INV_LOCATION'
    ,'PS_D_INVST_REASON'
    ,'PS_D_JOBCODE'
    ,'PS_D_JRNL_SOURCE'
    ,'PS_D_KK_BUDG_JNK'
    ,'PS_D_KK_BUDG_TYPE'
    ,'PS_D_KK_SOURCE_TRAN'
    ,'PS_D_LEDGER'
    ,'PS_D_LOT'
    ,'PS_D_MATCH_RULE'
    ,'PS_D_MRCHNT'
    ,'PS_D_MTCH_STATUS'
    ,'PS_D_OPER_UNIT'
    ,'PS_D_ORD_CAPTURE'
    ,'PS_D_ORIGIN'
    ,'PS_D_PATTERN_DAY'
    ,'PS_D_PERSON'
    ,'PS_D_PERSON_APOPID'
    ,'PS_D_PERSON_ARSPL'
    ,'PS_D_PERSON_COLTR'
    ,'PS_D_PERSON_CRNYST'
    ,'PS_D_PO_STATUS'
    ,'PS_D_PRJ'
    ,'PS_D_PRJ_AC'
    ,'PS_D_PRJ_AC_STAT'
    ,'PS_D_PRJ_CHNG'
    ,'PS_D_PRJ_HLTH'
    ,'PS_D_PRJ_ROLE'
    ,'PS_D_PRJ_RSRC'
    ,'PS_D_PRJ_RSRC_TYPE'
    ,'PS_D_PRJ_STAT'
    ,'PS_D_PRJ_TRAN_STAT'
    ,'PS_D_PRODUCT'
    ,'PS_D_PROGRAM_FDM'
    ,'PS_D_PRP'
    ,'PS_D_PRP_DTL'
    ,'PS_D_PY_TRMS_AR_VW'
    ,'PS_D_PYMNT_MTHD'
    ,'PS_D_RECLN_STATUS'
    ,'PS_D_RECV_STATUS'
    ,'PS_D_REQ_STATUS'
    ,'PS_D_REQLN_STATUS'
    ,'PS_D_RTRN_REASON'
    ,'PS_D_RTV_STATUS'
    ,'PS_D_RTVLN_STATUS'
    ,'PS_D_SALES_ORG'
    ,'PS_D_SCENARIO'
    ,'PS_D_SHIPTO'
    ,'PS_D_SO'
    ,'PS_D_SOURCE_TBL'
    ,'PS_D_STAT_CODE'
    ,'PS_D_SUPPLIER'
    ,'PS_D_TASK_TYPE'
    ,'PS_D_TIME'
    ,'PS_D_UOM'
    ,'PS_D_USER'
    ,'PS_D_WORK_CENTER'
    ,'PS_DEMAND_INF_INV'
    ,'PS_DEMAND_INV'
    ,'PS_DEPL_PLAN'
    ,'PS_DEPOSIT_CONTROL'
    ,'PS_DISTRIB_LIN'*/);
    begin
    for i in c1 loop
    dbms_lob.createtemporary(c, true);
    t := 'INSERT INTO DATA_PROFILE_COL_SUM ';
    dbms_lob.writeappend(c,length(t), t);
    --DBMS_OUTPUT.PUT_LINE(T);
    ----date
    FOR MYSQLTEXT IN (SELECT
    'select '
    || '''' || C.table_name || '''' || ' as tname, '
    || '''' || C.column_name || '''' || ' as cname, '
    || '''' || C.data_type || '''' || ' as data_type, '
    || '''' || nvl(c.data_length, 0) || '''' || ' as data_length, '
    || '''' || nvl(c.data_precision, 0) || '''' || ' as data_precision, '
    || '''' || nvl(c.data_scale, 0) || '''' || ' as data_scale, '
    || '''' || c.nullable || '''' || ' as nullable, '
    || '''' || nvl(c.num_distinct,0) || '''' || ' as num_distinct, '
    || '''' || nvl(c.density,0.0) || '''' || ' as density, '
    || '''' || nvl(c.num_nulls,0) || '''' || ' as num_nulls, '
    || '''' || nvl(c.char_col_decl_length,0) || '''' || ' as col_length, '
    || '''' || nvl(c.avg_col_len,0) || '''' || ' as avg_col_length, '
    || '''' || nvl(c.char_length,0) || '''' || ' as char_length, '
    || '''' || nvl(tblc.comments, 'NONE') || '''' || ' as table_comments, '
    || '''' || nvl(colc.comments, 'NONE') || '''' || ' as column_comments, '
    || ' count(*) as rcount, min('
    || c.column_name || ') as min_date, max('
    || c.column_name || ') as max_date, '
    || ' null as min_integer, null as max_integer, '
    || ' null as min_number, null as max_number, '
    || ' null as min_varchar2, null as max_varchar2, min(length('
    || c.column_name || ')) as min_len, max(length('
    || c.column_name || ')) as max_len, sysdate'
    || ' from '
    || C.owner || '.' || C.table_name
    || ' ' || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    left outer join sys.all_tab_comments tblc
    on t.owner = tblc.owner
    and t.table_name = tblc.table_name
    left outer join sys.all_col_comments colc
    on c.owner = colc.owner
    and c.table_name = colc.table_name
    and c.column_name = colc.column_name
    where c.owner = I.OWNER
    and c.data_type = 'DATE'
    and c.table_name = I.TABLE_NAME
    LOOP
    -- DBMS_OUTPUT.PUT_LINE(MYSQLTEXT.MYSQL);
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    ----number
    FOR MYSQLTEXT IN (select
    'select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || '''' || c.data_type || '''' || ' as data_type, '
    || '''' || nvl(c.data_length, 0) || '''' || ' as data_length, '
    || '''' || nvl(c.data_precision, 0) || '''' || ' as data_precision, '
    || '''' || nvl(c.data_scale, 0) || '''' || ' as data_scale, '
    || '''' || c.nullable || '''' || ' as nullable, '
    || '''' || nvl(c.num_distinct,0) || '''' || ' as num_distinct, '
    || '''' || nvl(c.density,0.0) || '''' || ' as density, '
    || '''' || nvl(c.num_nulls,0) || '''' || ' as num_nulls, '
    || '''' || nvl(c.char_col_decl_length,0) || '''' || ' as col_length, '
    || '''' || nvl(c.avg_col_len,0) || '''' || ' as avg_col_length, '
    || '''' || nvl(c.char_length,0) || '''' || ' as char_length, '
    || '''' || nvl(tblc.comments, 'NONE') || '''' || ' as table_comments, '
    || '''' || nvl(colc.comments, 'NONE') || '''' || ' as column_comments, '
    || ' count(*) as rcount, null as min_date, null as max_date, '
    || ' null as min_integer, null as max_integer, min('
    || c.column_name || ') as min_number, max('
    || c.column_name || ') as max_number, null as min_varchar2, null as max_varchar2, min(length('
    || c.column_name || ')) as min_len, max(length('
    || c.column_name || ')) as max_len, sysdate '
    || ' from '
    || t.owner || '.' || c.table_name
    || ' ' || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    left outer join sys.all_tab_comments tblc
    on t.owner = tblc.owner
    and t.table_name = tblc.table_name
    left outer join sys.all_col_comments colc
    on c.owner = colc.owner
    and c.table_name = colc.table_name
    and c.column_name = colc.column_name
    where c.owner = I.OWNER
    and c.data_type = 'NUMBER'
    and c.table_name = I.TABLE_NAME
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    --integer
    FOR MYSQLTEXT IN (select
    'select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || '''' || c.data_type || '''' || ' as data_type, '
    || '''' || nvl(c.data_length, 0) || '''' || ' as data_length, '
    || '''' || nvl(c.data_precision, 0) || '''' || ' as data_precision, '
    || '''' || nvl(c.data_scale, 0) || '''' || ' as data_scale, '
    || '''' || c.nullable || '''' || ' as nullable, '
    || '''' || nvl(c.num_distinct,0) || '''' || ' as num_distinct, '
    || '''' || nvl(c.density,0.0) || '''' || ' as density, '
    || '''' || nvl(c.num_nulls,0) || '''' || ' as num_nulls, '
    || '''' || nvl(c.char_col_decl_length,0) || '''' || ' as col_length, '
    || '''' || nvl(c.avg_col_len,0) || '''' || ' as avg_col_length, '
    || '''' || nvl(c.char_length,0) || '''' || ' as char_length, '
    || '''' || nvl(tblc.comments, 'NONE') || '''' || ' as table_comments, '
    || '''' || nvl(colc.comments, 'NONE') || '''' || ' as column_comments, '
    || ' count(*) as rcount, null as min_date, null as max_date, '
    || ' null as min_integer, null as max_integer, min('
    || c.column_name || ') as min_number, max('
    || c.column_name || ') as max_number, null as min_varchar2, null as max_varchar2, min(length('
    || c.column_name || ')) as min_len, max(length('
    || c.column_name || ')) as max_len, sysdate '
    || ' from '
    || t.owner || '.' || c.table_name
    || ' ' || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    left outer join sys.all_tab_comments tblc
    on t.owner = tblc.owner
    and t.table_name = tblc.table_name
    left outer join sys.all_col_comments colc
    on c.owner = colc.owner
    and c.table_name = colc.table_name
    and c.column_name = colc.column_name
    where c.owner = I.OWNER
    and c.data_type = 'INTEGER'
    and c.table_name = I.TABLE_NAME
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    --char and varchar
    FOR MYSQLTEXT IN (select
    'select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || '''' || c.data_type || '''' || ' as data_type, '
    || '''' || nvl(c.data_length, 0) || '''' || ' as data_length, '
    || '''' || nvl(c.data_precision, 0) || '''' || ' as data_precision, '
    || '''' || nvl(c.data_scale, 0) || '''' || ' as data_scale, '
    || '''' || c.nullable || '''' || ' as nullable, '
    || '''' || nvl(c.num_distinct,0) || '''' || ' as num_distinct, '
    || '''' || nvl(c.density,0.0) || '''' || ' as density, '
    || '''' || nvl(c.num_nulls,0) || '''' || ' as num_nulls, '
    || '''' || nvl(c.char_col_decl_length,0) || '''' || ' as col_length, '
    || '''' || nvl(c.avg_col_len,0) || '''' || ' as avg_col_length, '
    || '''' || nvl(c.char_length,0) || '''' || ' as char_length, '
    || '''' || nvl(tblc.comments, 'NONE') || '''' || ' as table_comments, '
    || '''' || nvl(colc.comments, 'NONE') || '''' || ' as column_comments, '
    || ' count(*) as rcount, null as min_date, null as max_date, '
    || ' null as min_integer, null as max_integer, '
    || ' null as min_number, null as max_number, min('
    || c.column_name || ') as min_varchar2, max('
    || c.column_name || ') as max_varchar2, min(length('
    || c.column_name || ')) as min_len, max(length('
    || c.column_name || ')) as max_len, sysdate'
    || ' from '
    || t.owner || '.' || c.table_name
    || ' ' || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    left outer join sys.all_tab_comments tblc
    on t.owner = tblc.owner
    and t.table_name = tblc.table_name
    left outer join sys.all_col_comments colc
    on c.owner = colc.owner
    and c.table_name = colc.table_name
    and c.column_name = colc.column_name
    where c.owner = I.OWNER
    and c.data_type in ('VARCHAR2', 'CHAR')
    and c.table_name = I.TABLE_NAME
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    e:='select null , null , null, null,null,null, null, null, null,null, null, null, null, null, null , null, null, null, null, null, null, null, null , null , null , null , null from dual where rownum < 0 ';
    dbms_lob.writeappend(c, length(e),e);
    execute immediate to_char(c);
    dbms_lob.createtemporary(c, true);
    t := 'insert INTO DATA_PROFILE_COL_DTL ';
    dbms_lob.writeappend(c,length(t), t);
    ----date
    FOR MYSQLTEXT IN (select
    ' select a.tname as table_name, a.cname as column_name, rownum as freq_rank, '
    || 'a.column_value as date_column_value, '
    || 'null as integer_column_value, null as number_column_value, null as varchar2_column_value, '
    || ' a.occurs, t.total_rows, round((((a.occurs * 1.0) / (t.total_rows * 1.0)) * 100), 5) as occurs_percent, '
    || ' a.capture_date'
    || ' from ( select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || c.column_name || ' as column_value, '
    || ' count(*) as occurs, sysdate as capture_date'
    || ' from '
    || t.owner || '.' || c.table_name
    || ' group by ' || c.column_name
    || ' order by count(*) desc )a inner join '
    || ' ( select ''' || c.table_name || ''' as tname, count(*) as total_rows from ' || t.owner || '.' || c.table_name || ') t '
    || ' on a.tname = t.tname where rownum <= 100'
    || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    where c.owner = i.owner
    and c.data_type IN ('DATE')
    and c.table_name = i.table_name
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    ----number
    FOR MYSQLTEXT IN (select
    ' select a.tname as table_name, a.cname as column_name, rownum as freq_rank, '
    || 'null as date_column_value, '
    || 'a.column_value as integer_column_value, null as number_column_value, null as varchar2_column_value, '
    || ' a.occurs, t.total_rows, round((((a.occurs * 1.0) / (t.total_rows * 1.0)) * 100), 5) as occurs_percent, '
    || ' a.capture_date'
    || ' from ( select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || c.column_name || ' as column_value, '
    || ' count(*) as occurs, sysdate as capture_date'
    || ' from '
    || t.owner || '.' || c.table_name
    || ' group by ' || c.column_name
    || ' order by count(*) desc )a inner join '
    || ' ( select ''' || c.table_name || ''' as tname, count(*) as total_rows from ' || c.table_name || ') t '
    || ' on a.tname = t.tname where rownum <= 100'
    || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    where c.owner = I.OWNER
    and c.data_type = 'INTEGER'
    and c.table_name = I.TABLE_NAME
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    --integer
    FOR MYSQLTEXT IN (select
    ' select a.tname as table_name, a.cname as column_name, rownum as freq_rank, '
    || 'null as date_column_value, '
    || 'null as integer_column_value, a.column_value as number_column_value, null as varchar2_column_value, '
    || ' a.occurs, t.total_rows, round((((a.occurs * 1.0) / (t.total_rows * 1.0)) * 100), 5) as occurs_percent, '
    || ' a.capture_date'
    || ' from ( select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || c.column_name || ' as column_value, '
    || ' count(*) as occurs, sysdate as capture_date'
    || ' from '
    || t.owner || '.' || c.table_name
    || ' group by ' || c.column_name
    || ' order by count(*) desc )a inner join '
    || ' ( select ''' || c.table_name || ''' as tname, count(*) as total_rows from ' || t.owner || '.' || c.table_name || ') t '
    || ' on a.tname = t.tname where rownum <= 100'
    || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    where c.owner = I.OWNER
    and c.data_type in ('NUMBER', 'DECIMAL')
    and c.table_name = I.TABLE_NAME
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    --char and varchar
    FOR MYSQLTEXT IN (select
    ' select a.tname as table_name, a.cname as column_name, rownum as freq_rank, '
    || 'null as date_column_value, '
    || 'null as integer_column_value, null as number_column_value, a.column_value as varchar2_column_value, '
    || ' a.occurs, t.total_rows, round((((a.occurs * 1.0) / (t.total_rows * 1.0)) * 100), 5) as occurs_percent, '
    || ' a.capture_date'
    || ' from ( select '
    || '''' || c.table_name || '''' || ' as tname, '
    || '''' || c.column_name || '''' || ' as cname, '
    || c.column_name || ' as column_value, '
    || ' count(*) as occurs, sysdate as capture_date'
    || ' from '
    || t.owner || '.' || c.table_name
    || ' group by ' || c.column_name
    || ' order by count(*) desc )a inner join '
    || ' ( select ''' || c.table_name || ''' as tname, count(*) as total_rows from ' || t.owner || '.' || c.table_name || ') t '
    || ' on a.tname = t.tname where rownum <= 100'
    || CHR(13) || chr(10) || ' UNION ALL ' AS MYSQL
    from sys.all_tab_columns c
    inner join sys.all_tables t
    on c.table_name = t.table_name
    and c.owner = t.owner
    where c.owner = I.OWNER
    and c.data_type in ('VARCHAR2', 'CHAR')
    and c.table_name = I.TABLE_NAME
    LOOP
    dbms_lob.writeappend(c, length(MYSQLTEXT.MYSQL),MYSQLTEXT.MYSQL);
    END LOOP;
    e:='select null, null, null, null, null, null, null, null, null, null, null from dual where rownum < 0 ';
    dbms_lob.writeappend(c, length(e),e);
    execute immediate to_char(c);
    end loop;
    end;

    Most likely issue is:
    execute immediate to_char(c); TO_CHAR will raise numeric or value error if c exeeds 4000 bytes. What Oracle version you are on? In newer versions execute immediate supports CLOB, so you can chnege the above to:
    execute immediate c;Keep in mind, execute immediate has 32K limit on SQL string.
    SY.

  • ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind

    Hi
    I am getting this run time error ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind in my pl/sql . I tried evrything , changing datatypes ,etc but still this error is coming .What can be the cause , please help.
    declare
    svid xxpor_utility.p_svid@sppmig1%type;
    p_sv_id xxpor_utility.p_svid@sppmig1%type;
    tab xxpor_utility.xxpor_indextab@sppmig1;
    svid1 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id1 xxpor_utility.p_svid@sppmig1%type;
    tab1 xxpor_utility.xxpor_indextab@sppmig1;
    svid2 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id2 xxpor_utility.p_svid@sppmig1%type;
    tab2 xxpor_utility.xxpor_indextab@sppmig1;
    svid3 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id3 xxpor_utility.p_svid@sppmig1%type;
    tab3 xxpor_utility.xxpor_indextab@sppmig1;
    v_index t2_error_table.id_value%type;
    v_code t2_error_table.error_code%type;
    p_error varchar2(600);
    k number(20):=0;
    v_msg varchar2(2000);
    v_commit_count number(10);
    v_at_gpid varchar2(512);
    v_at_oper varchar2(512);
    v_sch varchar2(512);
    v_vat varchar2(512);
    exp exception;
    exp1 exception;
    exp2 exception;
    exp3 exception;
    exp4 exception;
    v_pay varchar2(512);
    v_res varchar2(512);
    v_digit varchar2(512);
    v_agree varchar2(512);
    v_driver_licence PERSON_HISTORY.drivers_licence%TYPE;
    v_cus_gen1 number(10);
    v_cus_gen2 number(10);
    v_cus_gen3 number(10);
    svid_sr number(10);
    v_social PERSON_HISTORY.social_security_number%TYPE;
    CURSOR person_cur (p_person_id person_history.person_id%TYPE)
    IS
    SELECT drivers_licence ,social_security_number
    FROM PERSON_HISTORY@SPPMIG1
    WHERE PERSON_ID=p_person_id --p2(p).person_id
         AND EFFECTIVE_START_DATE = (SELECT MAX(EFFECTIVE_START_DATE)
         FROM PERSON_HISTORY@sppmig1
                                            WHERE PERSON_ID=p_person_id);--p2(p).person_id) ;
    --p number(20):=1;
    --j number(20);
    cursor c1 is
    select * from cus_node_his ;
    type temp_c1 is table of customer_node_history%rowtype
    index by binary_integer;
    t2 temp_c1;
    type temp_c2 is table of customer_node_history@slpmig1%rowtype
    index by binary_integer;
    p2 temp_c2;
    /*cursor c2(p_id customer_query.customer_node_id%type) is
    select general_1,general_2,general_3
    from customer_query@sppmig1 c where c.customer_query_type_id=10003 and
    c.customer_node_id(+) =p_id
    and c.open_date = (select
    max(open_date) from customer_query@sppmig1 where customer_node_id=p_id
    and customer_query_type_id=10003 and c.customer_query_id =(select max(customer_query_id) from customer_query@sppmig1
    where customer_node_id=p_id and customer_query_type_id=10003));*/
    procedure do_bulk_insert is
    bulk_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(bulk_errors, -24381);
    begin
    forall j in 1..t2.count SAVE EXCEPTIONS
    insert into aaa values t2(j);
    commit;
    --t2.delete;
    k:=0;
    v_msg:=sqlerrm;
    EXCEPTION WHEN bulk_errors THEN
    FOR L IN 1..SQL%bulk_exceptions.count
    LOOP
    v_index := SQL%bulk_exceptions(L).ERROR_INDEX;
    v_code := sqlerrm(-1 * SQL%bulk_exceptions(L).ERROR_CODE);
    --v_index := SQL%bulk_exceptions(j).ERROR_INDEX;
    --v_code := sqlerrm(-1 * SQL%bulk_exceptions(j).ERROR_CODE);
    INSERT INTO t2_error_table
    VALUES('CUSTOMER_NODE_HISTORY',
    'CUSTOMER_NODE_ID',
    v_msg,
    t2(v_index).customer_node_id,
    null,
    'DO_BULK_INSERT',
    v_code
    commit;
    END LOOP;
    end do_bulk_insert;
    begin
    select value into v_at_gpid from t2_system_parameter@sppmig1 where name='atlanta_group_id';
    select value into v_commit_count from t2_system_parameter@sppmig1 where name='batch_size';
    select value into v_sch from t2_system_parameter@sppmig1 where name='schedule_id';
    select value into v_pay from t2_system_parameter@sppmig1 where name='payment_location_code';
    select value into v_at_oper from t2_system_parameter@sppmig1 where name='atlanta_operator_id';
    select value into v_digit from t2_system_parameter@sppmig1 where name='digits_to_be_screened';
    select value into v_res from t2_system_parameter@sppmig1 where name='responsible_agent';
    select value into v_vat from t2_system_parameter@sppmig1 where name='vat_rate';
    select value into v_agree from t2_system_parameter@sppmig1 where name='bank_agreement_status';
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_TYPE_ID',tab);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CREDIT_RATING_CODE',tab2);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','PAYMENT_METHOD_CODE',tab3);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_STATUS_CODE',tab1);
    open c1;
    loop
    fetch c1 bulk collect into p2 limit v_commit_count;
    for p in 1..p2.count loop
    k:=K+1;
    begin
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CUSTOMER_NODE_TYPE_ID,tab,svid);
    p_sv_id:=svid;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CUSTOMER_NODE_STATUS_CODE,tab1,svid1);
    p_sv_id1 :=svid1;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CREDIT_RATING_CODE,tab2,svid2);
    p_sv_id2:=svid2;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).PAYMENT_METHOD_CODE,tab3,svid3);
    p_sv_id3:=svid3;
    OPEN person_cur (p2(p).person_id);
    FETCH person_cur INTO v_driver_licence, v_social;
    CLOSE person_cur;
    --select social_security_number  into v_social from person_history@sppmig1 where
    --PERSON_ID=p2(p).person_id AND EFFECTIVE_START_DATE = (SELECT MAX(EFFECTIVE_START_DATE) FROM
    --PERSON_HISTORY@sppmig1 WHERE PERSON_ID=p2(p).person_id) ;
    /*open c2(p2(p).customer_node_id);
    fetch c2 into v_cus_gen1, v_cus_gen2, v_cus_gen3;
    close c2;
    xxpor_utility.get_status_code@sppmig1(v_cus_gen1,v_cus_gen2,v_cus_gen3,svid_sr);*/
    svid_sr:=2600000;
    t2(k).CUSTOMER_NODE_ID     :=     p2(p).CUSTOMER_NODE_ID;
    t2(k).LAST_MODIFIED          :=     p2(p).LAST_MODIFIED;
    t2(k).EFFECTIVE_START_DATE     :=     p2(p).EFFECTIVE_START_DATE;
    t2(k).EFFECTIVE_END_DATE     :=     p2(p).EFFECTIVE_END_DATE;
    t2(k).CUSTOMER_NODE_TYPE_ID     := p_sv_id;
    if p_sv_id is null then
    raise exp1;
    end if;
    t2(k).PRIMARY_IDENTIFIER      :=     p2(p).PRIMARY_IDENTIFIER;
    t2(k).PRIMARY_IDENTIFIER2     :=     p2(p).PRIMARY_IDENTIFIER2;
    t2(k).NODE_NAME           :=     p2(p).NODE_NAME ;
    t2(k).NODE_NAME_UPPERCASE     :=     p2(p).NODE_NAME_UPPERCASE ;
    t2(k).NODE_NAME_SOUNDEX     :=     p2(p).NODE_NAME_SOUNDEX;
    t2(k).ATLANTA_GROUP_ID          := v_at_gpid ;
    t2(k).ATLANTA_OPERATOR_ID     :=     p2(p).ATLANTA_OPERATOR_ID;
    t2(k).GL_CODE_ID          :=     p2(p).GL_CODE_ID;
    t2(k).PARENT_CUSTOMER_NODE_ID     := p2(p).PARENT_CUSTOMER_NODE_ID ;
    t2(k).HIERARCHY_LEVEL          := p2(p).HIERARCHY_LEVEL ;
    t2(k).ROOT_CUSTOMER_NODE_ID      := p2(p).ROOT_CUSTOMER_NODE_ID ;
    t2(k).CUSTOMER_NODE_STATUS_CODE := p_sv_id1 ;
    if p_sv_id1 is null then
    raise exp2;
    end if;
    t2(k).CREATED_DATE     :=          p2(p).CREATED_DATE;
    t2(k).ACTIVE_DATE      :=          p2(p).ACTIVE_DATE ;
    t2(k).PERSON_ID     :=          p2(p).PERSON_ID ;
    t2(k).PRIME_ACCOUNT_ID :=          p2(p).PRIME_ACCOUNT_ID;
    t2(k).REPORT_LEVEL_CODE :=          p2(p).REPORT_LEVEL_CODE;
    t2(k).POSTAL_ADDRESS_ID     :=     p2(p).POSTAL_ADDRESS_ID;
    t2(k).SITE_ADDRESS_ID     :=     p2(p).SITE_ADDRESS_ID ;
    t2(k).CURRENCY_ID      :=          p2(p).CURRENCY_ID;
    t2(k).SCHEDULE_ID     :=          v_sch;
    t2(k).BILLING_PRIORITY     :=     p2(p).BILLING_PRIORITY ;
    t2(k).BILLING_COMPLEXITY:=          p2(p).BILLING_COMPLEXITY ;
    t2(k).BILLING_CONFIGURATION_CODE     := p2(p).BILLING_CONFIGURATION_CODE;
    t2(k).SUPPRESS_IND_CODE           := p2(p).SUPPRESS_IND_CODE ;
    t2(k).SUPPRESS_BILL_CYCLE_COUNT := p2(p).SUPPRESS_BILL_CYCLE_COUNT;
    t2(k).SUPPRESS_UNTIL_ISSUE_DATE := p2(p).SUPPRESS_UNTIL_ISSUE_DATE;
    t2(k).TURNOVER               := p2(p).TURNOVER;
    t2(k).TURNOVER_CURRENCY_ID      :=     p2(p).TURNOVER_CURRENCY_ID ;
    t2(k).CREDIT_LIMIT           :=     p2(p).CREDIT_LIMIT ;
    t2(k).CREDIT_LIMIT_CURRENCY_ID :=     p2(p).CREDIT_LIMIT_CURRENCY_ID;
    t2(k).EXPECTED_REVENUE      :=     p2(p).EXPECTED_REVENUE ;
    t2(k).EXPECTED_REVENUE_CURRENCY_ID     := p2(p).EXPECTED_REVENUE_CURRENCY_ID ;
    t2(k).CREDIT_RATING_CODE      :=     p_sv_id2 ;
    -- if p_sv_id2 is null then
    --raise exp3;
    -- end if;
    t2(k).CREDIT_COMMENTS           := p2(p).CREDIT_COMMENTS ;
    t2(k).TAX_CLASS_CODE          := 1     ;
    t2(k).PAYMENT_METHOD_CODE     :=     p_sv_id3;
    --if p_sv_id3 is null then
    --raise exp4;
    --end if;
    t2(k).PAYMENT_LOCATION_CODE      := v_pay ;
    t2(k).BANK_CODE           :=     NULL;
    t2(k).BRANCH_CODE           :=     NULL ;
    t2(k).BANK_ACCOUNT_NAME     :=     p2(p).NODE_NAME ;
    t2(k).BANK_ACCOUNT_NUMBER     :=     '1000000';
    t2(k).BANK_ACCOUNT_REF      :=     v_agree;
    t2(k).CARD_TYPE_CODE          := p2(p).CARD_TYPE_CODE     ;
    t2(k).CARD_NUMBER          :=     p2(p).CARD_NUMBER ;
    t2(k).CARD_EXPIRY_DATE          := NULL ;
    t2(k).ASSIGNED_OPERATOR_ID      :=     NULL ;
    t2(k).SALES_CHANNEL_CODE     :=     0;
    t2(k).COMPANY_NUMBER          := NULL;
    t2(k).INDUSTRY_CODE          :=     NULL;
    t2(k).REGION_CODE           :=     NULL;
    t2(k).GENERAL_1          :=     v_vat ;
    t2(k).GENERAL_2           :=     svid_sr ;
    if svid_sr is null then
    raise exp;
    end if;
    t2(k).GENERAL_3           :=     v_social ;
    t2(k).GENERAL_4           :=     v_driver_licence ;
    t2(k).GENERAL_5           :=     v_vat;
    t2(k).GENERAL_6           :=     v_res;
    t2(k).GENERAL_7           :=     null||':'||null||':'||'1000000'||':'||null||':'||null||':'||null||':';
    t2(k).GENERAL_8          :=     '2' ;
    t2(k).GENERAL_9           :=     v_digit;
    t2(k).GENERAL_10          :=     p2(p).CUSTOMER_NODE_ID;
    exception when exp then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;
    when exp1 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'customer_node_type_id is null');
    commit;
    when exp2 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'customer_node_status_code is null');
    commit;
    /*when exp3 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'credit_rating_code is null');
    commit;
    when exp4 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;*/
    when others then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;
    end;
    if mod(k,v_commit_count)=0 then
    do_bulk_insert;
    t2.delete;
    end if;
    end loop;
    do_bulk_insert;
    exit when c1%notfound;
    end loop;
    t2.delete;
    exception when others then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,null
    ,null,null,null);
    commit;
    RAISE;
    end;
    /

    Hi there,
    Following is the description of the error, you are getting.
    ORA-06502:VALUE_ERROR
    An arithmetic, conversion, truncation, or size-constraint error occurs. For example, when your program selects a column value into a character variable, if the value is longer than the declared length of the variable, PL/SQL aborts the assignment and raises VALUE_ERROR. In procedural statements, VALUE_ERROR is raised if the conversion of a character string into a number fails. (In SQL statements, INVALID_NUMBER is raised.)
    Hopefully this will help.

  • Numeric or Value Error 6502

    I have a stored procedure that starts out like so:
    PROCEDURE test_proc(param1 IN VARCHAR2, param2 IN VARCHAR2, param3 OUT
    SYS_REFCURSOR) IS
    v_var varchar2(5);
    BEGIN
    SELECT * FROM. . .
    The procedure tests fine in SQL Plus and PL/SQL Developer. When calling from
    ODP.NET like so. . .
    OracleCommand cmd = new OracleCommand("test_proc", <connection>);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("param1", "somevalue");
    cmd.Parameters.Add("param2", "XX");
    cmd.Parameters.Add("param3", OracleDbType.RefCursor,
    ParameterDirection.Output);
    DataSet ds = new DataSet();
    OracleDataAdapter da = new OracleDataAdapter(cmd);
    con.Open();
    da.fill(ds);
    con.Close();
    . . .the procedure executes as expected. If I change the value of
    param2 to "XXX" or any value three chars long I get the "ORA-06502:
    Numeric or Value Error at Line 1" error.
    Here's the kicker: I never constrain the size of that parameter or try to assign it to a variable! Why then should there be a numeric/value error?
    Anyone have any ideas?
    Thanks.

    Hi,
    Are you pointing to a 9206 database by chance? There was a known database bug that could cause that, and would be resolved by patching your database to 9208.
    Cheers,
    Greg

  • Pl/Sql numeric or value error

    Hi All,
    Does any one know if there is a bug in Oracle 8 related to date variable?
    This is the second time I am seeing very peculiar problem with date package variable as well as local variable.
    1) Few weeks back, I encountered problem with Date package variable, which is giving pl/sql numeric or value error,if you leave the session idle for few hours. When you connect back, the query runs just fine without any problem. To fix this I had to remove the date package variable.
    2)And now I am seeing that my job which calls the above package failing after running for long hours. It fails due to a local date variable with Pl/sql numeric or value error. Now, I am going to remove this variable also.
    Anyone has thoughts on this?
    Thanx for any inputs.

    Hi,
    I have solved by adding the following statement.
    DBMS_LOB.CREATETEMPORARY(theClob,cache=>false);
    Thanks,
    Rammu

  • Error ORA-06502, numeric or value error character to number conversion

    I have been trying to create an email including data from a table as part of the body. Whenever I try to send it, I get an error ORA-06502, numeric or value error, character to number conversion. If I take out the part referencing the table, the email will go without error, but if I put it back in I get the error.
    There is the code:
    DECLARE
    v_email_body CLOB;
    v_from_email_address VARCHAR2(100) := v('APP_USER');
    v_id NUMBER;
    BEGIN
    v_email_body := 'Please pay the attached invoice from FY '||:P14_FY||' funds
    Date: '||:P14_PURCHASE_DATE||'
    Vendor: '||:P14_VENDOR||'
    Invoice Number: '||:P14_INVOICE||'
    Invoice Date: '||:P14_INVOICE_DT||'
    Due Date: '||:P14_INVOICE_DUE_DT||'
    KSR Number: '||:P14_KSR||'
    DTS PO: '||:P14_DTS_PO||'
    FINANCE DO: '||:P14_FINANCE_PO||'
    FOR detail IN(SELECT OB_CODE
    FROM BUDGET_USED
    WHERE P_ID = :P14_ID)
    v_email_body := v_email_body||detail.OB_CODE||utl_tcp.crlf;
    LOOP
    FOR detail2 IN (SELECT ob_code, amount
    FROM budget_used
    WHERE p_id = :P14_ID)
    LOOP
    v_email_body := v_email_body||detail2.ELCID||' - '||detail2.AMOUNT||utl_tcp.crlf;
    END LOOP;
    END LOOP;
    v_email_body := v_email_body
    '||:P14_EMAIL_NOTES||'
    Thanks.
    v_id := APEX_MAIL.SEND
    (p_to => :P14_SUBMIT_TO
    ,p_cc => v('APP_USER')
    ,p_bcc => '[email protected]'
    ,p_from => v_from_email_address
    ,p_body => v_email_body
    ,p_subj => 'Invoice, '||:P14_VENDOR||', '||:P14_INVOICE||'');
    --Having set up your email, now add one (or more) attachments...
    FOR c1 in (SELECT FILENAME
    ,BLOB_CONTENT
    ,MIME_TYPE
    FROM file_subjects f, apex_application_files a
    where a.name = f.name
    and f.P_ID = :P14_ID) LOOP
    IF c1.blob_content IS NOT NULL THEN
    APEX_MAIL.ADD_ATTACHMENT( p_mail_id => v_id,
    p_attachment => c1.blob_content,
    p_filename => c1.filename,
    p_mime_type => c1.mime_type);
    END IF;
    END LOOP;
    END;
    Apex_mail.push_queue();
    This is important to my company to be able to put this data into an email. If anyone can help me, I would greatly appreciate it. Thank you in advance.

    Lets isolate the erroring line by running the code in debug mode and adding some debug lines at various stages in the code
    Apex has a builtin function named wwv_flow.debug which can print messages to the debug stack and would be visible when the page is run in debug mode.
    DECLARE
    v_email_body CLOB;
    v_from_email_address VARCHAR2(100) := v('APP_USER');
    v_id NUMBER;
    BEGIN
    wwv_flow.debug('BEGIN');
      v_email_body := 'Please pay the attached invoice from FY '||:P14_FY||' funds
      Date: '||:P14_PURCHASE_DATE||'
      Vendor: '||:P14_VENDOR||'
      Invoice Number: '||:P14_INVOICE||'
      Invoice Date: '||:P14_INVOICE_DT||'
      Due Date: '||:P14_INVOICE_DUE_DT||'
      KSR Number: '||:P14_KSR||'
      DTS PO: '||:P14_DTS_PO||'
      FINANCE DO: '||:P14_FINANCE_PO||'
      '||:P14_EMAIL_NOTES||'
      Thanks.
    wwv_flow.debug('Before sending mail');
      v_id := APEX_MAIL.SEND
      (p_to => :P14_SUBMIT_TO
      ,p_cc => v('APP_USER')
      ,p_bcc => '[email protected]'
      ,p_from => v_from_email_address
      ,p_body => v_email_body
      ,p_subj => 'Invoice, '||:P14_VENDOR||', '||:P14_INVOICE||'');
    wwv_flow.debug('Before attachements');
      --Having set up your email, now add one (or more) attachments...
      FOR c1 in
             (SELECT FILENAME
            ,BLOB_CONTENT
            ,MIME_TYPE
            FROM file_subjects f, apex_application_files a
            where a.name = f.name
            and f.P_ID = :P14_ID)
      LOOP
        IF c1.blob_content IS NOT NULL THEN
        APEX_MAIL.ADD_ATTACHMENT( p_mail_id => v_id,
        p_attachment => c1.blob_content,
        p_filename => c1.filename,
        p_mime_type => c1.mime_type);
        END IF;
      END LOOP;
    wwv_flow.debug('Finished attachements'); 
      Apex_mail.push_queue();
    END;What is the last message you see in the debug after running the page in debug mode and submitting it ?

  • Error:numeric or value error : buffer too small

    hi
    can any one please help me?
    i am developing the application in HTMLDB. i have an error numeric or value error: char buffer too small.
    i have an attributes plan_name,type......att_header1 in the database. The data's were inserted to the database, without the att_header item but if i have the item att_header int the HTMLDB then the insertion is not working. and also i was able to insert the data into the database for the field att_header1 through sql command . i think the problem is onle in my HTMLDB application.
    please tell me the solution for this error.
    thanx in advance
    valli
    Message was edited by:
    valli

    Valli,
    I don't think you understood my post, above:
    Can you please create an application that shows the problem on apex.oracle.com? Then we'll be able to see all your code together with the database tables, etc.
    If you do not have a workspace you can request one.
    Please request a workspace on apex.oracle.com. After your workspace request is approved, create an application there that shows this problem you are having. Create the necessary tables, packages, and other database objects in the database to support the example.
    As the last step, post here the workspace name, the application ID, and detailed instructions explaining how to use your application to demonstrate the problem.
    Scott

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

    HI All,
    I am facing the following issue and looking forward for help to find the cause.
    We are converting PDF documents in our repository to HTML using Oracle API
    ctx_doc.ifilter (v_datablob, v_dataclob);
    a highly simplified version of our code will be something like this..
    1) Create table to store the BLOB(Binary PDF documents)
    create table tbl_pdf_store(pdf_doc blob);
    2) Insert a row and store a PDF.
    3) Convert the PDF into HTML and store it in a CLOB object..
    DECLARE
    v_datablob BLOB;
    v_dataclob CLOB;
    BEGIN
    --Create temporary clob objects
    DBMS_LOB.createtemporary (v_dataclob, TRUE, DBMS_LOB.SESSION);
    DBMS_LOB.createtemporary (v_datablob, TRUE, DBMS_LOB.SESSION);
    --get the pdf to be converted from store table
    SELECT pdf_doc
    INTO v_datablob
    FROM tbl_pdf_store
    WHERE rownum < 1;
         --convert the BLOB to HTML and store it in CLOB
         ctx_doc.ifilter (v_datablob, v_dataclob);
    exception
         when others then
         dbms_output.put_line(sqlerrm||' - '||sqlcode);
    end;
    Now the issue I am facing is, the above code works fine for few documents and for few others I get this cryptic error message
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "CTXSYS.DRUE", line 180
    ORA-06512: at "CTXSYS.CTX_DOC", line 1142
    ORA-06502: PL/SQL: numeric or value error - -6502
    I cant reproduce the exact code here, but if anyone had faced the similar issue, then it would be great if they help me out.
    thanks,
    Prashant

    > Billy, its not just plain wrong its a sin :). "When
    others" should itself be avoided if possible(it just
    shows you don't know what error can occur). In the
    actual code, we are using separate package to handle
    and log errors. Here it was just for simplification I
    added that putline code.
    Phew.. You had me worried there... :-)
    > I ran my procedure in debug mode and it throws this
    exception when its executing the Oracle API
    ctx_doc.ifilter
    And there is very little you can do debugging that, as that source code is encoded (wrapped).
    Which means that unfortunately you have to treat that code as a black box and investigate the bug with respects to:
    a) the "environment" from which the call is made (ito of session settings, the sequence of calls made, etc)
    b) the data and parameters passed
    > this is not the case with all the PDFs..I was able to
    convert more than 11 thousand documents without any
    issues. I have this for only few hundred documents.
    This would seem to point to a bug in Oracle's CTX conversion/filter code. Maybe those PDFs are a newer version and is not correctly supported. Maybe they're an older version that is not supported.
    Which is why I said you need to isolate the error. Determine which PDFs are failing. Create a test harness (simplified code as you've posted) to perform a conversion (and nothing else).
    Determine which PDFs fail and which works. Look at the differences between PDFs. E.g. can those problem PDFs be opened with different Acrobat Reader version - or do some of them fail?
    > Another issue is I cannot view the content of the
    these documents to check if anything is different :(.
    You can with Acrobat Reader.. right?
    > so no sure how to go from here...is there a
    printstack method in Oracle 9i(similar to 10g I
    guess) which can give me more information as I am
    currently lost and not sure where to look.
    Dumping the stack will not be of much help. In fact, the error message sequence you pasted already show the call sequence. And as these are in Oracle PL/SQL code, there is nothing really you can do about it.
    My suggestion is to
    a) isolate the error
    b) consult the manual(s) to ensure that the Oracle PL/SQL s/w is used correctly
    c) determine if this is data related (e.g. different PDF versions for example)
    d) log a SR (Service Request) with Oracle Support
    The more you can do ito of (a) - (c), the better the chance for finding the root cause, and the quicker resolution when you have no choice but to do (d).

  • ORA-6502: PL/SQL: numeric or value error: character string buffer too small WWV-11230

    Hi,
    I'm trying to create an UI Template. I've generated the html using Frontpage and am successfully able to see in a browser.
    I've copied the html to the UI form, but when I try to preview or execute the UI template, I get the following error:
    Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-11230)
    null

    I AM FACING SIMILAR PROBLEM, THE EXACT ERROR IS:
    Error: Excepcisn de wwv_generate_component.build_procedure (WWV-01821)
    No se ha podido generar la pantalla de interfaz de usuario: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-16409)
    (SORRY , PART OF THE ERROR IS IN SPANISH!)
    I CREATED A FORM , WORKED WITH IT A LOT WITHOUT PROBLEMS. NOW I NEED TO DO SOME CHANGES ON CERTAIN FIELDS AND WHEN I TRY TO SAVE IT I GET THE ABOVE ERROR.
    THEN I GO BACK TO AN OLDER VERSION, COPY AND TRY TO DO CHANGES AND AGAIN THE ERROR COMES UP.
    THE CHANGES I AM TRYING TO DO ARE TO SOME OF THE EXISTING FIELDS IN THE FORM WHICH NEED TO BE PUT AS "INSERTABLE".
    THE SCREEN LAYOUT IS DISPLAYED WITHOUT PROBLEM.
    (THE FORM IS BASED ON A TABLE WITH APROX 80 FIELDS).
    I NEED SOME URGENT HELP. PLS LET ME KNOW ANY OTHER INFO YOU MAY NEED TO HELP ME SOLVE THIS PROBLEM.
    FYI I AM WORKING ON PORTAL VERSION 3.0.9 / ON Windows 2000 (DATABASE 8.1.7.0 AND iAS ARE ON DIFFERENT MACHINES).
    TKS IN ADVANCE

  • 6502 = ORA-06502: PL/SQL: numeric or value error: character string buffer

    i'm getting this error when i try to do the following
    6502 = ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    declare
    str1Query varchar2(32767);
    str2Query varchar2(32767);
    str3Query varchar2(32767);
    str31Query varchar2(32767);
    str32Query varchar2(32767);
    str4Query varchar2(32767);
    desc_t dbms_sql.desc_tab2;
    l_col_cnt integer;
    colvalue varchar(32676);
    cur_rows number;
    repCursor integer;
    begin
    repCursor := dbms_sql.open_cursor;
    dbms_sql.parse(repCursor,str1Query || ' ' || str2Query || ' ' || str3Query || ' ' || str31Query || ' ' || str32Query || str4Query,dbms_sql.native);
    dbms_sql.describe_columns2( repCursor, l_col_cnt, desc_t );
    DBMS_SQL.CLOSE_CURSOR (repCursor);
    end;
    if there is any ideas about what is wrong

    That is not the PL/SQL block that you have run to get that error, right?
    What are the sizes of the individual variables - str1Query, str2Query etc...
    Whay are there so many variables joined together?
    That posted code cannot generate the error you posted:
    SQL> declare
      2
      3  str1Query varchar2(32767);
      4  str2Query varchar2(32767);
      5  str3Query varchar2(32767);
      6  str31Query varchar2(32767);
      7  str32Query varchar2(32767);
      8  str4Query varchar2(32767);
      9  desc_t dbms_sql.desc_tab2;
    10  l_col_cnt integer;
    11  colvalue varchar(32676);
    12  cur_rows number;
    13  repCursor integer;
    14
    15  begin
    16
    17  repCursor := dbms_sql.open_cursor;
    18  dbms_sql.parse(repCursor,str1Query || ' ' || str2Query || ' ' || str3Query || ' ' || str31Query || ' ' || str32Query || str4Query,dbms_sql.native);
    19  dbms_sql.describe_columns2( repCursor, l_col_cnt, desc_t );
    20  DBMS_SQL.CLOSE_CURSOR (repCursor);
    21  end;
    22  /
    declare
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 826
    ORA-06512: at "SYS.DBMS_SQL", line 39
    ORA-06512: at line 18
    SQL>

Maybe you are looking for