ORA-06502 use TO_NUMBER TO_CHAR

Hello
Oracle Database 10g 10.2.0.5.0.

I have the error in this code:
nSuper_ NUMBER(6,2);
...
dbms_output.put_line('Super: ' ||  TO_NUMBER(nSuper_,'FM9G990D90'));
...
I have to use "TO_CHAR"... but my test is not failure, why? :
--a)
SET SERVEROUTPUT ON
DECLARE
  nSuper_ NUMBER(6,2);
BEGIN
  nSuper_ := 666.12;
  dbms_output.put_line('Super: ' ||  TO_NUMBER(nSuper_,'FM9G990D90'));

END;
/
Super: 666,12


--b)
SET SERVEROUTPUT ON
DECLARE
  nSuper_ NUMBER(6,2);
BEGIN
  nSuper_ := 6666.12;
  dbms_output.put_line('Super: ' ||  TO_NUMBER(nSuper_,'FM9G990D90'));

END;
/
DECLARE
*
ERROR en línea 1:
ORA-06502: PL/SQL: error  numérico o de valor
ORA-06512: en línea 5

--c)
SET SERVEROUTPUT ON
DECLARE
  nSuper_ NUMBER(6,2);
BEGIN
  nSuper_ := 6666.12;
  dbms_output.put_line('Super: ' ||  TO_CHAR(nSuper_,'FM9G990D90'));

END;
/
Super: 6.666,12
Why 'a' step missed and 'b' in case of failure?

Hello

jortri wrote:
Why 'a' step missed and 'b' in case of failure?

Because Oracle RDBMS is (too) soft on you for the conversion of 'simple' like that (but that does not mean that you will get errors...).

To_number function takes as input a string.
You send her a number, then Oracle does this: + "Ok this guy is sending a number in a TO_NUMBER function when it must be a string, we will do an implicit conversion for him in a transparent way" +. "
In fact, your to_number (my_number_variable, 'FM9G990D90') becomes this:

to_number( to_char(my_number_variable) ,'FM9G990D90')

But, as you can see, the function to_char is not given any format, so that it uses your default session, which might be a different way to the mask you provide to to_number function.

Please run this to understand what your failure to_number function receives as input:

select 6666.12 number_implicitly_converted from dual;

By default, on my computer it shows this:

Scott@my11g SQL>select 6666.12 number_implicitly_converted from dual;

NUMBER_IMPLICITLY_CONVERTED
---------------------------
                    6666.12

Now, if I use it as input of your with your format mask to_number function:

Scott@my11g SQL>select TO_NUMBER('6666.12','FM9G990D90') back_to_number from dual;
select TO_NUMBER('6666.12','FM9G990D90') back_to_number from dual
                 *
ERROR at line 1:
ORA-01722: invalid number

Tadammm!

Conclusion: Not to spoil use to_number/to_char/to_date functions.
:-)

Tags: Database

Similar Questions

  • ORA-06502 when you use MAX (Column) with % TYPE

    Hello

    I tried to limit the problem as much as I can and have managed to isolate a particular scenario. As the structure and sensitive data, I had to come up with a scenario that I tested it and it causes the same problem occurs. The scenario is as follows

    Assuming that I have a table defined as follows

    CREATE TABLE TEST_TABLE (TEST_COLUMN CHAR (8 BYTES));

    and the table has only one record NZ07100S

    We also define a function as

    CREATE OR REPLACE FUNCTION
    FUNCTION GETTESTVALUE
    TEST_TABLE RETURN. TYPE % TEST_COLUMN
    IS
    TEST_VALUE TEST_TABLE. TYPE % TEST_COLUMN;
    BEGIN
    SELECT MAX (TEST_COLUMN) IN TEST_VALUE TEST_TABLE;
    RETURN TEST_VALUE;
    END;



    We ran the following command

    SELECT GETTESTVALUE FROM DUAL;

    and receive an error as follows

    Error report:
    SQL error: ORA-06502: PL/SQL: digital or value error: character string buffer too small
    ORA-06512: at "GETTESTVALUE", line 6
    06502 00000 - "PL/SQL: digital error or the value of %s.


    However, if were to change the function of the following

    CREATE OR REPLACE FUNCTION
    FUNCTION GETTESTVALUE
    TEST_TABLE RETURN. TYPE % TEST_COLUMN
    IS
    TEST_VALUE TEST_TABLE. TYPE % TEST_COLUMN;
    BEGIN
    SELECT TEST_COLUMN IN TEST_VALUE TEST_TABLE;
    RETURN TEST_VALUE;
    END;

    There is no error reported and the value nz07100s is returned.

    Of course, when we changed the function is

    CREATE OR REPLACE FUNCTION
    FUNCTION GETTESTVALUE
    TEST_TABLE RETURN. TYPE % TEST_COLUMN
    IS
    TEST_VALUE TEST_TABLE. TYPE % TEST_COLUMN;
    BEGIN
    SELECT CAST (MAX (TEST_COLUMN) AS CHAR (8)) IN TEST_VALUE TEST_TABLE;
    RETURN TEST_VALUE;
    END;

    No error is reported, and the value is returned

    However, the function in question is in the use of production since 2004. We are currently a few changes to the application and imported the backup of Oracle 10 g Oracle XE. When we try to run the function, the error is thrown.

    I would like to understand if this is a limitation with Oracle XE that causes this problem. It seems to me that the problem is to select the MAX value in the variable that has been set. Executing the query directly from sqlplus does not generate an error, and therefore do not feel there is an error with the SQL code. The only time that we can't get the error is with the INTO statement.

    Is there a way to use the function as it has been defined in production? Why the ORA-06502 error would be thrown? It does not seem to make sense to me. Would appreciate any guidance on this.


    Thanks and greetings

    Jega

    Thank you

    What happens if you do this and rerun the select

    SQL>alter table test_table modify test_column varchar2 (8 byte);
    

    Edit:
    You may need to open a SR with Oracle on this one
    (Really, financial system on XE?)

    Concerning
    Peter

    Published by: Peter on March 4, 2009 12:58 AM

  • ORA-06502 error digital or value of PL/SQL.

    Hi experts,

    Oracle Apex 4.2, 11g database, using windows 7.

    I created a form and trying to create automatically generated # (sequence of not) with logic and SQL.

    My requirement is to generate the good good exercise only and exercise begin from 01 July and ends 30 June each year. This means if the 07/01/2015 start it will create a new voucher No.

    The table name is GL_PV and the columns are:

    Number of PV_No

    Date of PV_Date

    Number of CC_code

    number amount

    Remarks varchar2 (100)

    What I did: -.

    Created a process to submit before the calculations and validations.

    Code are

    IF TO_NUMBER (TO_CHAR (: P15_pv_date, 'MM')) < = 6 THEN

    SELECT MAX (to_number (nvl(pv_no,0))) + 1

    IN: P15_pv_no

    OF GL_PV

    WHERE pv_date

    BETWEEN

    TO_DATE ('01 - JUL' |) ' -'|| (TO_NUMBER (TO_CHAR(:P15_pv_date,'YYYY'))-1), 'DD-MON-YY')

    AND

    TO_DATE (30 - JUN'|) ' -'|| To_char(:P15_pv_date,'YYYY'), 'DD-mon-YY')

    and cc_code =: P15_cc_code;

    ON THE OTHER

    SELECT MAX (to_number (nvl(pv_no,0))) + 1

    IN: P15_pv_no

    OF GL_PV

    WHERE pv_date

    BETWEEN

    TO_DATE ('01 - JUL' |) ' -'|| To_char(:P15_pv_date,'YYYY'), 'DD-mon-YY')

    AND

    TO_DATE (30 - JUN'|) ' -'|| (TO_NUMBER (TO_CHAR(:P15_pv_date,'YYYY')) + 1), 'DD-MON-YY')

    and cc_code =: P15_cc_code;

    END IF;

    If: P15_pv_no is null then

    : P15_pv_no: = 1;

    end if;

    and press the button when Conditions = Generate_Button

    I have the default assign to pv_date = sysdate, when I launched the point Pv_date form shows the current date and I click on Generate_button now show error.

    Error ORA-06502 PL/SQL digital or value. Conversation number character.

    One last thing, I checked this code already in TOAD, type I assigned as DATE-value = 10/11/2014 (today's date) works fine without error.

    Please guide what this evil is stated.

    Best regards

    : P15_pv_date is probably not a date but a varchar2 in Apex

    Try this

    NVL SELECT (MAX (to_number (nvl(pv_no,0))) + 1, 1)

    IN: P15_pv_no

    OF GL_PV

    WHERE pv_date

    BETWEEN to_date (' 01-07-' |) (extract (year of to_date (: P15_pv_date, "dd-mm-yyyy")) + case when extracted (months to_date (: P15_pv_date, "dd-mm-yyyy")))<= 6="" then="" -1="" else="" 0="" end="" ),="" 'dd-mm-yyyy'="">

    AND to_date (30 - 06-' |) (extract (year of to_date (: P15_pv_date, "dd-mm-yyyy")) + case when extracted (months to_date (: P15_pv_date, "dd-mm-yyyy")))<= 6="" then="" 0="" else="" 1="" end="" ),="" 'dd-mm-yyyy'="">

    and cc_code =: P15_cc_code;

  • ORA-06502: PL/SQL: digital or value error: character of error number

    Hello gurus,

    I get the following error:
    ORA-06502: PL/SQL: digital or value error: character of number conversion error

    It happens on wizard generated in a table.
    DECLARE
    v_venue_prsntd_qtr varchar2(3);
    v_venue_prsntd_fy  number;
    
    BEGIN
    FOR i IN 1 .. apex_application.g_f02.COUNT
      LOOP
        IF apex_application.g_f05 (i) IS NOT NULL THEN 
            v_venue_prsntd_qtr := 
             Case WHEN TO_CHAR(apex_application.g_f05 (i), 'MON') IN ('OCT','NOV','DEC') THEN '1'
                  WHEN TO_CHAR(apex_application.g_f05 (i), 'MON') IN ('JAN','FEB','MAR') THEN '2'
                  WHEN TO_CHAR(apex_application.g_f05 (i), 'MON') IN ('APR','MAY','JUN') THEN '3'
                  ELSE '4'
                  END;
      -- INTO v_venue_prsntd_qtr
      -- FROM venue_prsntd
      -- WHERE venue_prsntd_seqno = apex_application.g_f02 (i) 
      -- AND dfcy_seqno = apex_application.g_f03 (i)
      -- AND apex_application.g_f05 (i) IS NOT NULL; 
    ----fiscal year
     --    v_venue_prsntd_fy := 
     --       CASE WHEN TO_CHAR(TO_NUMBER(TO_CHAR(apex_application.g_f05(i), 'MMDD'))) < 1001 THEN --------TO_CHAR(apex_application.g_f05 (i),'YYYY')
    --        ELSE TO_CHAR(TO_NUMBER(TO_CHAR(apex_application.g_f05 (i),'YYYY')) + 1) 
    --      END;
    
       --  INTO v_venue_prsntd_fy
       --  FROM venue_prsntd
       --  WHERE venue_prsntd_seqno = apex_application.g_f02 (i) 
       --  AND dfcy_seqno = apex_application.g_f03 (i) 
       --  AND apex_application.g_f05 (i) IS NOT NULL; 
       --  
    ---END IF;
      --- IF apex_application.g_f02 (i) IS NULL AND apex_application.g_f05 (i) IS NOT NULL Then 
              -- INSERT INTO venue_prsntd(venue_prsntd_qtr, venue_prsntd_fy)
              --                   VALUES(v_venue_prsntd_qtr, v_venue_prsntd_fy);
                 UPDATE VENUE_PRSNTD
                      SET VENUE_PRSNTD_QTR = to_number(v_venue_prsntd_qtr)
                         -- VENUE_PRSNTD_FY = v_venue_prsntd_fy
                 WHERE VENUE_PRSNTD_SEQNO = APEX_APPLICATION.G_F03(i);
    END IF;
    END LOOP;
    END;
    I'm trying to update venue_prsntd_qtr. I commented all the rest to see if I can limit the error is coming from.

    QTR is a numeric field in the database. I have gone back and forth with the variable type in the code and still get the same error.

    I use oracle db 10g, apex 3.2.1

    Thank you
    Mary

    Hi, I don't think it's possible to integrate with the routine auto mru. What you can do is to use a trigger to insert database after the cessation of the to do.

    Otherwise, you will still need a separate process Apex which runs after the SRM process.

    Luis

  • ORA-06502 on cursor fetch dba_triggers

    Oracle 11.2.0.3 SE - One

    Oracle Linux 5.6, 64-bit

    I watched it until I'm blue in the face...

    Procedure uses a loop of CURSOR to scroll dba_triggers and disabling selected triggers.  Going through the result set, I get

    ERROR on line 1:

    ORA-06502: PL/SQL: digital error or value

    ORA-06512: at "ESTEVENS. TRUNCATE_SCHEMA', line 66

    ORA-06512: at line 1

    I think I have identified as a particular line by ordering my SELECT cursor, the two ascendant and descendant and is the line that should be the next one is the same of the order.  For example, assume that the returned rows are named "AAA", "BBB", "CCC", etc..  If I includes an ORDER BY ASC TRIGGER_NAME, the last row before reports error is "FFF", then any error during playback of what should be 'GGG '.  If I ORDER BY DESC TRIGGER_NAME, the last row reports until the error is "HHH", even once any error during playback of what should be 'GGG '.

    Code of procedure is

    create or replace

    procedure truncate_schema (i_schema in varchar2)

    is

    type usrtbl_typ is ref cursor return % ROWTYPE dba_tables;

    cv_usrtbl usrtbl_typ;

    v_usrtbl dba_tables % ROWTYPE;

    type usrconstraint_typ is ref cursor return sys.dba_constraints%ROWTYPE;

    cv_usrconstraint usrconstraint_typ;

    v_usrconstraint sys.dba_constraints%ROWTYPE;

    type usrtrigger_typ is ref cursor return sys.dba_triggers%ROWTYPE;

    cv_usrtrigger usrtrigger_typ;

    v_usrtrigger sys.dba_triggers%ROWTYPE;

    date of T_DATE;

    v_sql varchar2 (20000);

    number of v_rowcnt;

    Start

    Select sysdate in double T_DATE;

    dbms_output.put_line ('Run time is' | to_char (T_DATE,' dd-mon-yyyy hh24:mi:ss'));))

    --

    dbms_output.put_line (' processing user ' | i_schema);

    --

    -Disable all triggers on the tables in the selected schema

    --

    dbms_output.put_line (' '... triggers ");

    Select count (*)

    in v_rowcnt

    of dba_triggers

    where table_owner = i_schema;

    dbms_output.put_line (' treatment ' | v_rowcnt |) "triggers");

    v_rowcnt: = 0;

    Open the cv_usrtrigger for

    Select * from sys.dba_triggers

    where table_owner = i_schema

    order by the owner,

    trigger_name desc;

    loop

    extract the cv_usrtrigger in v_usrtrigger;

    When the output cv_usrtrigger % NOTFOUND;

    v_sql: = 'alter trigger' |

    v_usrtrigger. Owner |

    '.' ||

    v_usrtrigger.trigger_name |

    "disable."

    v_rowcnt: = v_rowcnt + 1;

    dbms_output.put_line (v_rowcnt |') -' || v_sql);

    -execution immediate v_sql;

    end loop;

    close cv_usrtrigger;

    end truncate_schema;


    The sample output:


    SQL > exec truncate_schema ('DW')

    Run time is June 5, 2014 10:56:09

    Processing user DW

    ... triggers

    Treatment of 54 triggers

    1 - alter trigger DW. < delete name for public consumption >

    2 - alter trigger DW. < delete name for public consumption >

    -snip unnecessary repetition-

    30 - alter trigger DW. < delete name for public consumption >

    BEGIN truncate_schema ('DW'); END;

    *

    ERROR on line 1:

    ORA-06502: PL/SQL: digital error or value

    ORA-06512: at "ESTEVENS. TRUNCATE_SCHEMA', line 66

    ORA-06512: at line 1

    SQL >


    I was starting to suspect may be a corruption of data dictionary (stable in the dev database), but I was able to repeat the error (and on the same named trigger!) in another data base which is a DUPLICATE of the production of rman.


    Oops, I missed you select all of the columns in dba_triggers. You probably have a trigger with TRIGGER_BODY > 64767 bytes. Exclude TRIGGER_BODY go select and I'm almost certain that you will be OK.

    SY.

  • Getting Ora-06502: PL/SQL of Numeric or value error.

    Hello

    I m getting the following error when a calculation for form fields.

    ""Server Ajax Call returned error Ora-06502: PL/SQL digital error or value ".

    I m using the dynamic action to calculate my value fields display. Here is the code of my DA.

    (Required value) event: change

    Selection type (required): product (s)

    Article (s) (required): P141_PROP_COST, P141_DOWNPAY_AMT, P141_PREM_PERC, P141_DOWNPAY_PERC, P141_PREM_AMT



    Begin

    : P141_TOTAL_SELL_PRICE: =: P141_DOWNPAY_AMT +: P141_PREM_AMT;

    : P141_COMM_AMT: =: P141_TOTAL_SELL_PRICE*.02;

    : P141_TOTAL_SELL_PRICE_FEE: =: P141_TOTAL_SELL_PRICE +: P141_TRANSFER_COST +: P141_COMM_AMt;

    : P141_INST_REM_AMT: =: P141_PROP_COST-: P141_DOWNPAY_AMT;

    End;

    Page point to presented: P141_PROP_COST, P141_DOWNPAY_AMT, P141_PREM_AMT, P141_TRANSFER_COST

    Return point page: P141_TOTAL_SELL_PRICE, P141_COMM_AMT, P141_TOTAL_SELL_PRICE_FEE, P141_INST_REM_AMT

    I m using another DA for the calculation and validation of my form fields rest. Here is the code:

    {$("#P141_DOWNPAY_PERC").change (function ()}

    var x = ($("#P141_DOWNPAY_PERC").val () / 100) * $("#P141_PROP_COST").val ();

    $("#P141_DOWNPAY_AMT").val (x);

    });

    {$("#P141_DOWNPAY_AMT").change (function ()}

    If ($("#P141_DOWNPAY_AMT").val () > $("#P141_PROP_COST").val ())

    {

    Alert ("section may be no greater than the basic price");

    }

    on the other

    {var y = ($("#P141_DOWNPAY_AMT").val () / ($("#P141_PROP_COST").val ())) * 100;}

    y = Math.Round (y);

    $("#P141_DOWNPAY_PERC").val (y) ;}

    });

    {$("#P141_PREM_PERC").change (function ()}

    var x = ($("#P141_PREM_PERC").val () / 100) * $("#P141_PROP_COST").val ();

    $("#P141_PREM_AMT").val (x);

    });

    {$("#P141_PREM_AMT").change (function ()}

    If ($("#P141_PREM_AMT").val () > $("#P141_PROP_COST").val ())

    {

    Alert ("section may be no greater than the basic price");

    }

    on the other

    {var z = ($("#P141_PREM_AMT").val () / ($("#P141_PROP_COST").val ())) * 100;}

    z = Math.Round (z);

    $("#P141_PREM_PERC").val (z) ;}

    });

    Any help.

    Concerning

    Pa

    'Problems of implicit conversion' comes to mind when I see this:

    : P141_TOTAL_SELL_PRICE: =: P141_DOWNPAY_AMT +: P141_PREM_AMT;

    This is similar to the problems I've seen when using the default formats for the Date Picker Item Types.

    I will add in some APEX_DEBUG. MESSAGE() lines to check what are the string values.

    (remember, all bind variables are of type VARCHAR2)

    You should maybe explicitly to convert strings to numbers using TO_NUMBER() and include the appropriate format.

    (a bit like you have to do with the conversion of strings to dates.)

    My $0.02 worth

    MK

  • ORA-06502: PL/SQL: digital error: error in the conversion of char to number

    Hello world.

    I have a strange problem here. I'll try to explain better. I work with APEX 4.2 and of Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production.

    Here are my parameters NLS_SESSION_PARAMETER and NLS_DATABASE_PARAMETER: NLS_NUMERIC_CHARACTERS,.


    I have a table with a lot of body numbers, and when I imported a MS Access application data, all fields were imported with the comma as decimal separator.


    Now, I have a form with several fields of number and when I leave a numeric field, a body of numbers of amount total is calculated and automatically filled with a bit of javascript.


    Now the problem: calculating fields (sum) succeeds only when I use the decimal as the delimiter. If I use the comma, I get a NaN value in the total amount field. I managed to convert all commas in points with javascript, so the total amount is calculated.

    When I try to save the record, I get the error: ORA-06502: PL/SQL: digital error: error in the conversion of char to number because I'm trying to save the separator point in my number fields.


    I tried to use REPLACE function to replace the. by one, before winning but does not solve the problem.


    This sounds familiar to anyone?


    Thanks in advance.



    OK, the problem is solved people.

    Somehow, the registration procedure had an influence on another calculation of my form and the error came from this process. So I put a to_number and replace stated in the calculation and all records very well and it shows my total.

  • FRM-40735 when-pressed to release raised unhandled exception ora-06502 button?

    I write the following procedure

    PROCEDURE p73_fragment_metar (p_metar in varchar2, varchar2, out p_dy Code_P varchar2, p_hr out varchar2,)
    p_dd number, p_ff series, p_tt number of p_dp number, p_qnh number.
    p_mn out varchar2, p_year out varchar2)
    IS
    -p_metar varchar2 (500);
    str_date_code Varchar2 (500);
    code varchar2 (10);
    DY varchar2 (10);
    HR varchar2 (10);

    str_dd_ff Varchar2 (500);
    JJ varchar2 (10);
    VARCHAR2 (10) FF.;

    str_tt_dp varchar2 (500);
    TT varchar2 (10);
    VARCHAR2 (10) DP;

    qnh_str varchar2 (500);
    QNH varchar2 (10);

    DAT varchar2 (20);
    MNTH varchar2 (20);
    VARCHAR2 (10) years;


    BEGIN
    -p_metar: = 'OJAM 171600Z 32010KT 5000 HZ SCT030 11/05 Q1023 NOSIG';
    str_date_code: = substr (p_metar, 1, length (DelimStr.GetString (p_metar, 1, FALSE, 'Z')) + 2);
    Code: = substr (str_date_code, 1, length (str_date_code)-9);
    Code_P: = code;

    dy: = substr (str_date_code, length-7 (str_date_code), 2);
    p_dy: = dy;

    HR: = substr (str_date_code, length-5 (str_date_code), 4);
    p_hr: = h;


    -- --------------------------------------------------------------------------------------
    -str_dd_ff: = substr (p_metar, 1, length (DelimStr.GetString (p_metar, 1, FALSE, 'KT')) + 0);
    -dd: = substr (str_date_code, length-5 (str_dd_ff), 3);
    DD: = substr (p_metar, 14, 3);
    p_dd: = to_number (dd);

    FF: = substr (p_metar, 17, 2);
    p_ff: = to_number (ff);

    -- --------------------------------------------------------------------------------------
    str_tt_dp: = substr (p_metar, 1, length (DelimStr.GetString (p_metar, 1, FALSE, ' /')) + 3);

    TT: = substr (str_tt_dp, length-5 (str_tt_dp), 3);
    p_tt: = to_number (tt);

    DP: = substr (str_tt_dp, length (str_tt_dp)-1, 3);
    p_dp: = to_number (dp);
    -- -------------------------------------------------------------------------------------
    qnh_str: = substr (p_metar, 1, length (DelimStr.GetString (p_metar, 1, FALSE, 'Q')) + 5);
    QNH: = substr (qnh_str, length (qnh_str)-3, 5);
    p_qnh: = to_number (qnh);

    -- -------------------------------------------------------------------------------------
    Select to_char (sysdate) in DUAL from SWD;
    month: = substr (dat, length (dat)-5, 3);
    p_mn: = mnth;
    years: = '20'. substr (dat, length (dat)-1, 3);
    p_year: = years;
    -- ---------------------------------------------------------------------------------
    / * p05_show_alert_message (code);
    p05_show_alert_message (dy);
    p05_show_alert_message (HR);
    p05_show_alert_message (DD);
    p05_show_alert_message (FF);
    p05_show_alert_message (TT);
    p05_show_alert_message (DP);
    p05_show_alert_message (QNH);
    p05_show_alert_message (MNTH);
    p05_show_alert_message (years); * / This loaded message to be sure and beach t each variable is it has the correct value


    END;


    I try to call hollow a trigger when the button as follows

    Declare
    p_metar varchar2 (500);
    Code_P varchar2 (10);
    p_dy varchar2 (10);
    p_hr varchar2 (10);

    p_dd number (4.4);
    p_ff number (4.4);

    p_tt number (4.4);
    p_dp number (4.4);
    p_qnh number (4.4);

    p_mn varchar2 (20);
    p_year varchar (10);

    Begin
    p_metar: = 'OJAM 171600Z 32010KT 5000 HZ SCT030 11/05 Q1023 NOSIG';

    p73_fragment_metar (p_metar, Code_P, p_dy, p_hr, p_dd, p_ff, p_tt, p_dp, p_qnh, p_mn, p_year);

    END;


    When the p73_fragment_metar PROCEDURE is called, I receive the following error message:
    FRM-40735 when-pressed to release raised unhandled exception ora-06502 button?

    Don't know if this is the reason, but are you sure that it is correct

    p_dd number (4.4);

    This means that you put a number with no figures before the commae and 4 digits after the decimal point, means you can't store something like 1 in it.

  • Ideas for work around ORA-06502: character string buffer too small on the interactive report

    Hello

    It comes to Apex 4.2.  We try to create an interactive report.  The report is for something similar at a follow-up time.  We try to concat a comments column as the sum of the hours.  For example,.

    Select TASK_NAME, sum (HOURS), to_char (XMLAGG (XMLELEMENT(E,E.COMMENTS ||) ' : ')). Extract ('//Text ()'). GETSTRINGVAL()) USER_COMMENTS of...

    This query works fine if we seek only to a window of 1 week.  The question that we live, when we expand the scope of the query to include data from 3 months, we hit ORA-06502 interactive report.  If we remove this column from the interactive report, then the report works very well.

    Anyone has any ideas on how we might be able to work around this problem?  I'm guessing we're reached the limit of 32 k on the report.  Ideally, we would show just the last X number of comments and then have a link to show all comments

    Any help would be appreciated

    Thank you

    Mike

    ListAGG raises an ORA-01489 for varchar2 > 4000 bytes

    OP has an ORA - 06502--> IR is running within a limit of 4 k / 32 k.

    quick fix: wrap USER_COMMENTS ListAGG in a substr (..., 1, 4000)

    Longer solution, use a subquery to modify comments based on ROW_NUMBER() (IE after the nth line, change the null)

    with
    -- simulating data
    t as (select task_id, sysdate - lv as date_entered
      ,round(dbms_random.value(1,24)) hours
      , '-*' || lv || '.' || task_id || '*-' as user_comments
    from ( select level as task_id from dual connect by level <=10 ), (select level lv from dual connect by level < 1000)
    ),
    -- modify data
    modified_data as (
      select task_id, hours, date_entered
        ,case
          when row_number() over (partition by task_id order by date_entered desc) < 5
            then user_comments
          else null
         end USER_COMMENTS
        from t)
    select task_id, sum(hours) total_hours,
      listagg( user_comments  ) within group (order by date_entered desc)
      || case when count(*) >= 5 then '! MORE COMMENTS !' else null end
        as user_comments
    from modified_data
    group by task_id;
    
  • Generation XML problem in APEX ORA-06502

    Hi, I have a problem with the generation of XML, I developed an application in the APEX, and in an html page, I have this process: +.

    declare
    l_XML varchar2 (32767).
    Start
    .......
    Select xmlElement
    (
    "iva"
    xmlElement ("numeroRuc", J.RUC),
    xmlElement ("razonSocial", J.RAZON_SOCIAL),
    xmlElement ("idRepre", J.ID_REPRE),
    xmlElement ("rucContador", J.RUC_CONTADOR),
    xmlElement ("anio", J.ANIO),
    xmlElement ("my", J.MES),

    xmlElement
    (
    "shopping."
    (
    Select xmlAgg
    (
    xmlElement
    (
    "detalleCompra,"
    -xmlAttributes (K.ID_COMPRA like "COMPRA"),
    xmlForest
    (
    K.COD_SUSTENTO as "codSustento."
    K.TPLD_PROV as "tpldProv."
    K.ID_PROV as "idProv."
    K.TIPO_COMPROBANTE as "tipoComprobante."
    TO_CHAR (K.FECHA_REGISTRO, ' DD/MM/YYYY "") as "fechaRegistro."
    K.ESTABLECIMIENTO as "food."
    K.PUNTO_EMISION as "puntoEmision."
    K.SECUENCIAL as "secuencial".
    TO_CHAR (K.FECHA_EMISION, ' DD/MM/YYYY "") as "fechaEmision."
    K.AUTORIZACION as 'autorizacion. "
    TO_CHAR (K.BASE_NO_GRA_IVA, 9999999999.99) as "baseNoGraIva."
    TO_CHAR (K.BASE_IMPONIBLE, 9999999999.99) as "baseImponible."
    TO_CHAR (K.BASE_IMP_GRAV, 9999999999.99) as "baseImpGrav."
    TO_CHAR (K.MONTO_ICE, 9999999999.99) as "montoIce."
    TO_CHAR (K.MONTO_IVA, 9999999999.99) as "montoIva."
    TO_CHAR (K.VALOR_RET_BIENES, 9999999999.99) as "valorRetBienes."
    TO_CHAR (K.VALOR_RET_SERVICIOS, 9999999999.99) as "valorRetServicios."
    TO_CHAR (K.VALOR_RET_SERV_100, 9999999999.99) as 'valorRetServ100 '.
    ),
    xmlElement
    (
    'air ',.
    (
    Select xmlAgg
    (
    xmlElement
    (
    "detalleAir,"
    xmlForest
    (
    P.COD_RET_AIR as "codRetAir."
    TO_CHAR (P.BASE_IMP_AIR, 9999999999.99) as "baseImpAir."
    TO_CHAR (P.PORCENTAJE_AIR, 999.99) as "porcentajeAir."
    TO_CHAR (P.VAL_RET_AIR, 9999999999.99) as 'valRetAir '.
    )
    )
    )
    ANEXO_COMPRAS p
    where P.ID_COMPRA = K.ID_COMPRA
    AND P.ID_INFORMANTE_XML = K.ID_INFORMANTE_XML
    )
    ),
    xmlElement ("estabRetencion1", K.ESTAB_RETENCION_1),
    xmlElement ("ptoEmiRetencion1", K.PTO_EMI_RETENCION_1),
    xmlElement ("secRetencion1", K.SEC_RETENCION_1),
    xmlElement ("autRetencion1", K.AUT_RETENCION_1),
    xmlElement ("fechaEmiRet1", to_char(K.FECHA_EMI_RET_1,'DD/MM/YYYY'));
    xmlElement ("docModificado", K.DOC_MODIFICADO),
    xmlElement ("estabModificado", K.ESTAB_MODIFICADO),
    xmlElement ("ptoEmiModificado", K.PTO_EMI_MODIFICADO),
    xmlElement ("secModificado", K.SEC_MODIFICADO),
    xmlElement ("autModificado", K.AUT_MODIFICADO)
    )
    )
    SRI_COMPRAS k
    WHERE K.ID IS NOT NULL
    AND K.ID_INFORMANTE_XML = J.ID_INFORMANTE
    AND K.ID BETWEEN 1 AND 25
    )
    )
    ). getClobVal()
    in l_XML
    ANEXO_INFORMANTE j
    where J.ID_INFORMANTE =: P3_MES
    and J.RUC =: P3_ID_RUC
    and J.ANIO =: P3_ANIO
    and J.MES =: P3_MES;

    -HTML
    sys.owa_util.mime_header('Text/XML',false);
    sys. HTP.p ("Content-Length: ' |") length (l_XML));
    sys.owa_util.http_header_close;
    sys. HTP. Print (l_XML);
    end;



    Now my table contains over 900 lines and only when I specifically chose 25 rows of the table "ANEXO_COMPRAS" in the case (AND K.ID BETWEEN 1 AND 25) the generated XML.

    I think the problem may be with the data type that is declared 'varchar2', but I tried with "CLOB" data type, and the error is the same. +

    declare
    l_XML CLOB.
    Start
    -View XML
    sys. HTP.init;
    wwv_flow.g_page_text_generated: = true;
    wwv_flow.g_unrecoverable_error: = true;

    -Select XML
    Select xmlElement
    ( .......

    )
    SRI_COMPRAS k
    WHERE K.ID IS NOT NULL
    AND K.ID_INFORMANTE_XML = J.ID_INFORMANTE
    .........
    ). getClobVal()
    in l_XML
    ANEXO_INFORMANTE j
    where J.ID_INFORMANTE =: P3_MES
    and J.RUC =: P3_ID_RUC
    and J.ANIO =: P3_ANIO
    and J.MES =: P3_MES;

    -HTML
    sys.owa_util.mime_header('Text/XML',false);
    sys. HTP.p ("Content-Length: ' |") length (l_XML));
    sys.owa_util.http_header_close;
    sys. HTP. Print (l_XML);
    end;

    The error generated is ORA-06502: PL/SQL: digital error or value+ _

    Please I need your help. I don't know how to solve this problem, how to use the 'CLOB' data type to the XML file can be generating+.

    Published by: JohannaCevallos07 on 26-sep-2012 10:52

    In the DECLARE section:

    l_xml       clob;
    chunk_size  pls_integer := 32767;
    

    then replace

    htp.print(l_XML);
    

    with the loop:

    for i in 0..trunc((dbms_lob.getlength(l_xml) - 1) / chunk_size)
    loop
      htp.prn( dbms_lob.substr(l_xml, chunk_size, 1 + i*chunk_size) );
    end loop;
    
  • ORA-06502: PL / SQL: numeric or value error: character string buffer too small

    Dear friends,

    We have a package customized for FTP PLSQL.
    I get ORA-06502: PL/SQL: digital or value error: character string buffer too small when the FTP service running.
    The FTP function call the HOST function that is in fact to launch the above mentioned error.
    Here is the code for FTP and HOST functions.
    FUNCTION HOST(text_in    IN VARCHAR2,
               result_out IN OUT VARCHAR2) RETURN BOOLEAN IS
    ret boolean;
    drun boolean;
    hid number;
    BEGIN
       dbms_output.put_line('host1 begin');
       ret := HOST(text_in,result_out,hid,drun,1);
       if not drun then
         dbms_output.put_line('not derun');
          return false;
       end if;
         dbms_output.put_line('after if');
       return ret;
    END HOST;
    FUNCTION GET_ENV(env IN VARCHAR2) RETURN VARCHAR2 IS
     res boolean;
     out varchar2(256);
    BEGIN
      res := HOST('echo '||env,out);
      return out;
    END GET_ENV;
    FUNCTION HOST(text_in      IN VARCHAR2,
              result_out IN OUT VARCHAR2,
              hostid     IN OUT NUMBER ,
              demrunning IN OUT boolean,
              maxlines   IN NUMBER DEFAULT NULL) RETURN BOOLEAN IS
      tempid      number;
      tempstat      varchar2(10);
      n           number;
      m           number;
      retry      number;
      mult           number;
      timestamp_date  date;
      lv_result_out varchar2(200);
    BEGIN
      --result_out := NULL; --fcxh76
      demrunning := true;
      dbms_output.put_line('host2 begin');
      select XXAR_SHELL_CMD_S.nextval
      into  tempid from dual;
      hostid := tempid;
    
      dbms_pipe.pack_message(tempid);
      n := dbms_pipe.send_message('CMD');
    
      dbms_pipe.pack_message(abs(maxlines));
      dbms_pipe.pack_message(rtrim(text_in));
      n := dbms_pipe.send_message ('CMD'||rtrim(to_char(tempid)),0);
    
      m := dbms_pipe.receive_message('CMDSTAT'||rtrim(to_char(tempid)),5);
      if m = 1 then
          demrunning := false;
          dbms_output.put_line('m=1');
          result_out := 'ERROR : GLCC0005 presumed not running';
          dbms_output.put_line('result_out - '||result_out);
          return FALSE;
      elsif m = 0 then
         dbms_pipe.unpack_message(tempstat);
      end if;
    
      if tempstat = 'ERROR' then
         dbms_output.put_line('tempstat = ERROR');
         result_out := NULL;
         dbms_output.put_line('after result out');
         return FALSE;
      end if;
    <<CHECK_AGAIN>>
         m := dbms_pipe.receive_message('RSLT'||rtrim(to_char(tempid)),0);
    
    if m <> 0 then
        goto CHECK_AGAIN;
    end if;
    
         if m = 0 then
                dbms_pipe.unpack_message(result_out);
                dbms_pipe.purge('RSLT'||rtrim(to_char(tempid)));
                return TRUE;
         else
             result_out := 'ERROR : Call to GLCC0006 failed';
             return FALSE;
         end if;
    END HOST;
    FUNCTION FTP (program_name in VARCHAR2,
               source_file in VARCHAR2,
               dest_file   in VARCHAR2 default NULL) RETURN BOOLEAN
    AS
    fd               utl_file.file_type;
    res            boolean;
    res1           boolean;
    out            varchar2(256);
    out1           varchar2(256);
    ftp_dnsname      varchar2(50);
    ftp_user         varchar2(50);
    ftp_pass         varchar2(50);
    ftp_pre_opt      varchar2(150);
    ftp_post_opt     varchar2(150);
    ftp_override     varchar2(150);
    destination_file varchar2(50);
    ftp_command      varchar2(2000);
    ftp_main         varchar2(2000);
    proc_id           varchar2(10);
    fderr             varchar2(100);
    rec           varchar2(1024);
    temp_buf      varchar2(100);
    base_source       varchar2(100);
    log_dir              varchar2(100) := get_env('$APPLCSF')||'/log';
    fndc_logfile_dir varchar2(100) := 'FNDC_LOGFILE_DIR';
    i            number ;
    ftp_tried        boolean;
    begin
     ftp_tried := false;
     dbms_output.put_line('begin');
    for ftp_rec in ( select  attribute1,
                       attribute2,
                       attribute3,
                       attribute4,
                       nvl(attribute5,' ') attribute5,
                       nvl(attribute6,' ') attribute6,
                       nvl(rtrim(attribute7),'put') attribute7
              from fnd_flex_values
              where  flex_value_set_id in
              (select flex_value_set_id
               from fnd_flex_value_sets
               where flex_value_set_name = 'CPC_FTPS'
              )
              and flex_value like program_name
              )
         LOOP
                 dbms_output.put_line('Looping');
               ftp_tried := true;
              ftp_dnsname      := ftp_rec.attribute1;
              ftp_user         := ftp_rec.attribute2;
              ftp_pass         := ftp_rec.attribute3;
              destination_file := ftp_rec.attribute4;
              if dest_file is not null then
                 destination_file := dest_file;
                    end if;
    
                                   if destination_file is null then
                    destination_file := base_name(source_file);
                end if;
                ftp_pre_opt      := ftp_rec.attribute5;
              ftp_post_opt     := ftp_rec.attribute6;
              ftp_override     := lower(ftp_rec.attribute7);
              dbms_output.put_line('host');
    
              res := HOST('echo $$',proc_id);
              dbms_output.put_line('proc_id - '||proc_id);
         dbms_output.put_line('after host');
         base_source := rtrim(base_name(source_file));
           dbms_output.put_line('host 1');
           res := HOST('>  '||log_dir||'/ftpcmd.'||proc_id ||
              ' ; chmod 777 '||log_dir||'/ftpcmd.'||proc_id,out1);
           dbms_output.put_line('host 2');
           res := HOST('>  '||log_dir||'/ftpmain.'||proc_id ||
              ' ; chmod 777 '||log_dir||'/ftpmain.'||proc_id,out1);
           dbms_output.put_line('host 3');
           res := HOST('>  '||log_dir||'/ftplog.'||proc_id ||
              ' ; chmod 777 '||log_dir||'/ftplog.'||proc_id,out1);
           dbms_output.put_line('host completed');
    ......
    ......
    ......
    Here is the PLSQL block that I will carry out and also the output on this block
    declare 
    lv_ftp_result boolean; 
    begin 
    lv_ftp_result := u.FTP('XXAR_REV_PA', ' ' || '/u07/app/qaoa083a/data/outgoing/xxar/PARECREV' || '/' || 'REVENUE_20120319014318.dat','REVENUE_20120319014318.dat');  
    IF lv_ftp_result THEN 
    dbms_output.put_line('True'); 
    ELSE 
    dbms_output.put_line('False'); 
    END IF; 
    exception 
    when others then 
    dbms_output.put_line('in exception - '||sqlerrm); 
    end;
    Output:
    host1 begin
    host2 begin
    m=1
    result_out - ERROR : GLCC0005 presumed not running
    not derun
    begin
    Looping
    host
    host1 begin
    host2 begin
    m=1
    in exception - ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    The flow of execution goes like this:
    1 FTP function called from PL/SQL block
    2 inside of the FTP service, the Sub statement calls the HOST function
    log_dir              varchar2(100) := get_env('$APPLCSF')||'/log';
    3. This HOST function in turn calls another function of overloaded HOST (code shown above).
    4. in the function overloaded with the HOST, the following statements are executed successfully, and FALSE is returned by the function
    dbms_output.put_line('m=1');
    result_out := 'ERROR : GLCC0005 presumed not running';
    dbms_output.put_line('result_out - '||result_out);
    5. the remaining code in the FTP service is running and the HOST function is called again using the Sub statement
    res := HOST('echo $$',proc_id);
    6.again, this HOST function in turn calls another function of overloaded HOST (code posted above).
    7. this time, in the function overloaded host, ORA-06502 is thrown when the following statement is executed and the execution stops here that this exception is unhandled.
    result_out := 'ERROR : GLCC0005 presumed not running';
    This statement is very successfully in the previous call to the function of HOST (step 4), but it fails now.

    Any idea on why this error occurs in this scenario? Because the issue of memory?

    DB Info:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    Kind regards
    Anthony

    Published by: Anthony Alix on March 20, 2012 08:53

    Hello

    HOST (1) calls the function of MODERATOR (2) with his second parameter as result_out

    The first time you call the function of host (1) in the function get_env you use

    ...
     out varchar2(256);
    BEGIN
      res := HOST('echo '||env,out);
    ...
    

    out is big enough varchar2 (256)

    The second time you call (1) HOST of the FTP function as:

    ...
    ftp_main         varchar2(2000);
    proc_id           varchar2(10);
    fderr             varchar2(100);
    ...
    
    ...
              res := HOST('echo $$',proc_id);
              dbms_output.put_line('proc_id - '||proc_id);
    ...
    

    Here, use you proc_id which is varchar2 (10)

    And it's not big enough!

    Kind regards

    Peter

  • When button pressed - trigger raised unhandled exception ORA-06502

    Hi all

    I am currently implementing a hierarchy tree, using these codes on

    When button pressed

    DECLARE
    htree point;
    my_sql VARCHAR2 (200): = ' select 1, level, hee_name, null, to_char (hee_no)
    of hrm_employee
    Connect prior hee_id = hee_dirsup_id
    Start with hee_dirsup_id is null
    order of brothers and sisters in hee_name';
    BEGIN
    htree: = FIND_ITEM ("trees.tree10");
    Ftree. SET_TREE_PROPERTY (htree, ftree.query_text, my_sql);
    Ftree. POPULATE_TREE ("htree");
    END;

    I can't see my hierarchical tree and I get the above error message.
    Is someone can you please help me sort this out? Are there pieces of missing codes resulting from this error.

    I'll be very grateful for any help :)

    Germany.

    Hi Germany

    trigger an unhandled exception thrown ORA-06502

    * Cause: this error occurs when you try to assign a value to a variable, but the value is greater than the variable can handle.
    or if you try to assign a nonnumeric value to a numeric variable.

    --=========================

    Action *: pls change the VARCHAR2 my_sql * (200) * to my_sql VARCHAR2 * (2000). *

    I can't see my hierarchical tree

    Pls take a look here: code sample Andreas Weiden....

    I hope this helps...

    Kind regards

    Amatu Allah.

  • apex_json throws ORA-06502

    Hello

    I use 5 APEX and must work with GEOJSON.

    If I test the following statement in SQL Developer, everything works fine:

    DECLARE
        s varchar2(32767) := '{ "a": 1, "b": ["hello", "world"]}';
    BEGIN
        apex_json.parse(s);
        sys.dbms_output.put_line('a is '||apex_json.get_varchar2(p_path => 'a'));
    END;
    

    But if I change the JSON data to the following:

    s varchar2(32767) := '{ "a": 1.1, "b": ["hello", "world"]}';
    

    I get this error:

    Fehler beim Start in Zeile : 1 in Befehl -
    DECLARE
        s varchar2(32767) := '{ "a": 1.1, "b": ["hello", "world"]}';
    BEGIN
        apex_json.parse(s);
        sys.dbms_output.put_line('a is '||apex_json.get_varchar2(p_path => 'a'));
    END;
    Fehlerbericht -
    ORA-06502: PL/SQL: numerischer oder Wertefehler: Fehler beim Konvertieren von Zeichen zu Zahl
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 367
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 519
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 566
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 756
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 774
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 811
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 839
    ORA-06512: in "APEX_050000.WWV_FLOW_JSON", Zeile 852
    ORA-06512: in Zeile 4
    06502. 00000 -  "PL/SQL: numeric or value error%s"
    *Cause:    
    *Action:
    

    The same thing happens with with MyMethod...

    sys.dbms_output.put_line('a is '||apex_json.get_number(p_path => 'a'));
    

    Because I work with GEOJSON, there are decimal numbers in my JSON data - I have to deal with.

    I have not found any suspicion in the apex_json documentation.

    How can I solve this problem?

    Kind regards

    Christian

    Hello

    your example works fine for me on 5.0.2. There were a few bugs that fixed us since 5.0. Some may be available as SAFF, but maybe you need to upgrade to the latest version.

    Kind regards

    Christian

  • Process apex Pl/SQL error: ORA-06502: PL/SQL: digital error or value: specified incorrect LOB Locator

    Apex 4.2

    I searched through the forums of the research about this error, but I do not understand what to do from here. I am writing a process that sends an e-mail when a value of the claim is made (or on a button click). Procedure is as follows:

    DECLARE
       l_body        clob;
       l_body_html   clob;
       l_subject    varchar2(100);
    
    BEGIN
      
    l_body := empty_clob();
    l_body_html := empty_clob();
    
    
    IF V('REQUEST') in ('SAVE_ME') AND :P32_PARENT_UPDATED_FL IS NOT NULL THEN
       l_subject :=  'Survey Job Request Updated'||utl_tcp.crlf||utl_tcp.crlf;
       l_body := 'Update'||utl_tcp.crlf;
    
       l_body_html := '<html>
          <head>
             <style type = "text/css">
                 /* Can add style attributes later */
             </style>
          </head>
          <body>'||utl_tcp.crlf;
       l_body_html := l_body_html ||'Survey Job Request has been updated.<br /><br />'||utl_tcp.crlf;
       l_body_html := l_body_html ||'Title: '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_TITLE||utl_tcp.crlf;
       l_body_html := l_body_html ||'<br />Request Category : '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_REQUEST_CATEGORY||utl_tcp.crlf;
       l_body_html := l_body_html ||'<br />Update Date: '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_UPDATE_DATE||utl_tcp.crlf;
       l_body_html := l_body_html ||'<br />Updated By: '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_LAST_EDITED_BY_USERID||utl_tcp.crlf;
       l_body_html := l_body_html ||'</body></html>';
    
    
    
    
    
    END IF;
    
    :P32_CANCELLATION_REASON := l_body_html;
    
    apex_mail.send(
       p_to             =>  '[email protected]',
       p_from           =>  '[email protected]',
       p_body           =>  l_body_html,
       p_body_html      =>  l_body_html,
       p_subj           =>  l_subject);
    
    END;
    
    
    
    
    
    
    
    
    
    

    I added two lines to the code (lines 08 and 09) and when I run my program, I now get the error:

    • ORA-21560: 3 argument is null, invalid or out of range

    Without these two lines, I received the error:

    ORA-06502: PL/SQL: digital error or value: specified incorrect LOB Locator

    I'm not quite sure what is wrong or what I can change. There seems to be right, and in fact, it worked before. I have no idea why this error keeps popping up. Any help on that would be great. Thanks in advance.

    Hello

    NewApexCoder wrote:

    Hmmm... good point. I think that apex_mail.send must be called inside the IF block. But in the future, I added several conditional statements, won't I need to include the apex_mail.send function in each IF block? But at the same time, there is the case that if no conditional instructions are met? Tests, when none of the conditions are true (when I had a second IF block in the code), an email would not be defined, which is correct. Could that be causing a problem however. If the IF block is not filled could he always try to send an email about anything or the l_body_html and l_subject fields have in them the garbage that causing ORA error?

    If the call to the procedure of sending (it is a procedure, and not a function) many times is necessary or useful depends on exactly what you're trying to do.

    For example, you can write to Santa for

    • Submit a wish list
    • Change of address
    • Contradiction with your boss, who can you tell Santa you were mean

    or any combination of these grounds.  If you want to send a simple email whenever any of the conditions are met (and not send a when none are met), then you could do something like this:

    DECLARE

    need_to_send BOOLEAN: = FALSE;

    ...

    BEGIN

    ...

    IF wish_list IS NOT NULL

    THEN

    l_body: = l_body | ...

    need_to_send: = TRUE;

    END IF;

    IF old_addresss <> new_address

    THEN

    l_body: = l_body | ...

    need_to_send: = TRUE;

    END IF;

    IF boss_is_a_big_fat_liar

    THEN

    l_body: = l_body | ...

    need_to_send: = TRUE;

    END IF;

    IF need_to_send

    SO - It's the only call to send

    apex_mail. Send...

    In any case, the error message ' ORA-21560: argument 3 sucks...» "is pretty clear: If you have not given a value to everything you're passing as p_body, then you'd better call the procedure.

  • DBMS_STATS.gather_schema_stats: ORA-06502

    I am trying to run under block to find all objects with stale stats. Is someone can you please tell me what I'm missing?

    Set serveroutput on;

    DECLARE

    ObjList dbms_stats. ObjectTab;

    BEGIN

    DBMS_STATS. GATHER_SCHEMA_STATS (ownname = > null, OPTIONS = > "LIST out of DATE", objlist = > ObjList);

    FOR i IN ObjList.FIRST... ObjList.LAST

    LOOP

    dbms_output.put_line (ObjList (i). ObjName | ' ' || ObjList (i). Type of the object);

    END LOOP;

    END;

    /

    ORA-06502: PL/SQL: digital error or value

    ORA-06512: at line 5

    06502 00000 - "PL/SQL: digital error or the value of %s.

    * Cause: A digital arithmetic error, String, conversion or coercion

    has occurred. For example, this error occurs if an attempt is made to

    assign the NULL value to a variable declared NOT NULL, or if a

    attempt to assign an integer greater than 99 to a variable

    NUMBER (2) declared.

    * Action: Change the data, how it is handled, or how it is so declared

    that values do not violate the constraints.

    Using the Oracle 12 c on Windows 7 version

    You do not currently have all stale stats, so the dbms_stats. ObjectTab is empty.  Take into account:

    SQL > create type test_type as the object)

    col1 2 varchar2 (10));

    3.

    Type of creation.

    SQL > create type test_tab as table of test_type.

    2.

    Type of creation.

    SQL > declare

    l_tt 2 test_tab;

    3. start

    4. Select test_type (dummy)

    5 bulk collect into l_tt

    6 double

    7 where 1 = 2;

    8 because I in l_tt.first... l_tt loop. Last

    9 dbms_output.put_line (l_tt (i) .col1);

    10 end of loop;

    11 end;

    12.

    declare

    *

    ERROR on line 1:

    ORA-06502: PL/SQL: digital error or value

    ORA-06512: at line 8 level

    You should test if there is in fact no value before attempting to access the object.

    SQL > declare

    l_tt 2 test_tab;

    3. start

    4. Select test_type (dummy)

    5 bulk collect into l_tt

    6 double

    7 where 1 = 2;

    8 if l_tt.count > 0 then

    9 because loop me in l_tt.first... l_tt. Last

    10 dbms_output.put_line (l_tt (i) .col1);

    11 end of loop;

    12 on the other

    13 dbms_output.put_line ('no statistics obsolete');

    14 end if;

    15 end;

    16.

    No stale stats

    PL/SQL procedure successfully completed.

    John

Maybe you are looking for