Questions tagged [ora-06502]

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

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

You tried to tried to execute a statement that resulted in an arithmetic, numeric, string, conversion, or constraint error. This error can be caused by many circumstances. The following are two examples of how to resolve this Oracle error:

  1. This error occurs when you try to assign a value to a numeric variable, but the value is larger than the variable can handle.

    For example, if you had the following PLSQL code:

    DECLARE
       v_number number(2);
    BEGIN
       v_number := 100;
    END;
    

    You've tried to assign a 3 digit number to a variable called v_number that can only handle 2 digits. You could correct this error by redefining the v_number variable as number(3).

    DECLARE
      v_number number(3);
    BEGIN
      v_number := 100;
    END;
    
  2. This error also occurs if you are trying to assign a non-numeric value to a numeric variable.

    For example, if you had the following PLSQL code:

    DECLARE
      v_number number(2);
    BEGIN
      v_number := 'a';
    END;
    

    In this example, the value of 'a' does not properly convert to a numeric value. You can correct this error by assigning the variable called v_number a proper numeric value.

33 questions
60
votes
8 answers

How to query a CLOB column in Oracle

I'm trying to run a query that has a few columns that are a CLOB datatype. If i run the query like normal, all of those fields just have (CLOB) as the value. I tried using DBMS_LOB.substr(column) and i get the error ORA-06502: PL/SQL: numeric or…
Catfish
  • 18,876
  • 54
  • 209
  • 353
7
votes
6 answers

Using Ref Cursor in Oracle SQL Developer

I am using Oracle SQL Developer, but I am having an issue seeing results from a package that returns a ref cursor. Below is the package definition: CREATE OR REPLACE package instance.lswkt_chgoff_recov as type rec_type is record …
Wade73
  • 4,359
  • 3
  • 30
  • 46
6
votes
2 answers

Using DBMS_LOB.SUBSTR on a BLOB results in ORA-06502

When I try to run the dbms_lob.substr function on a BLOB field, I get the following error: ORA-06502: PL/SQL: numeric or value error: raw variable length too long ORA-06512: at line 1 My query: select dbms_lob.substr(my_report, 10000, 1) from…
Zach Green
  • 3,421
  • 4
  • 29
  • 32
5
votes
1 answer

How to minimize the coupling/dependency between physical DDL changes and PL/SQL changes?

We ran into a particular issue with our Oracle table definition (DDL) and in one of our PL/SQL scripts. The issue is, there was a change in the table, changing from varchar(20) to varchar(30), this change however, was not diligently reflected in one…
Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215
3
votes
1 answer

PlSql Translate function question

I've created a cursor to select the actual data, and loop through it outputting the raw value and the value after it was converted to a number. The application occasionally throws invalid number errors. Below is my test (not including the select…
Matt M
  • 3,699
  • 5
  • 48
  • 76
2
votes
1 answer

6502 from ODP.NET on a function returning string

I have a SQL function defined as such: create or replace function func_cmap_unit_test (what varchar2) return varchar2 as begin return 'hello ' || what || '!'; end func_cmap_unit_test; I tested in SQL Developer and it works fine: select…
Johnny Wu
  • 1,297
  • 15
  • 31
2
votes
4 answers

Problem with oracle stored procedure - parameters

I have this stored procedure: CREATE OR REPLACE PROCEDURE "LIQUIDACION_OBTENER" ( p_Cuenta IN NUMBER, p_Fecha IN DATE, p_Detalle OUT LIQUIDACION.FILADETALLE%TYPE ) IS BEGIN SELECT FILADETALLE INTO p_Detalle FROM Liquidacion …
Nicole
  • 1,356
  • 3
  • 21
  • 41
2
votes
1 answer

Erroneous Oracle numeric or value error

I have an ongoing issue in which a windows service gets this Oracle error: Message: ORA-06502: PL/SQL: numeric or value error: character to number conversion error However, I am sure that I am passing a numeric value to Oracle. Working with our…
Don Chambers
  • 3,798
  • 9
  • 33
  • 74
1
vote
1 answer

No result from a query stored in a VARCHAR2 variable is treated as an empty string or a NULL? - Oracle PL/SQL - Oracle 11g

I have a procedure which performs a SELECT INTO and stores the returned result in a VARCHAR2 variable called account_: SELECT DISTINCT NVL(XYZ_API.Get_Ref(company, currency, pay_type, order_id), XYZ_API.Get_Id(company, currency,…
Uthpala Dl
  • 45
  • 8
1
vote
0 answers

ORA-06502 "number precision too large" only in PL/SQL Developer

There is a package with type. CREATE OR REPLACE PACKAGE MY_TYPES IS PRAGMA SERIALLY_REUSABLE; SUBTYPE my_number IS NUMBER(3,0); END MY_TYPES; / There is a procedure: DECLARE PROCEDURE print(my_number_i IN my_types.my_number) IS BEGIN …
Dki0m7
  • 11
  • 2
1
vote
1 answer

ORA-06502 in a stored procedure

Hello I have this simple procedure that compiles fine but after I initialize the variables the error is this. The table is created like this Create table vcelar_pomocky ( cislo_nakupu Number(5,0) NOT NULL , cislo_ula Number(5,0) NOT NULL , …
Kekuw
  • 35
  • 5
0
votes
1 answer

Numeric or value error: character to number conversion error

create or replace procedure prdBandwidth is cursor c_bandwidth is select distinct mt.name bwname,b.circuitno circuitno,subapp.customerno customerno,netinfo.bandwidthtype bandwidthtype from wom.tbltsubscriberapplication…
0
votes
1 answer

Oracle exception information

I'm wondering if there is a way to get a little more information about what caused the exception: Error starting at line 5 in command: exec .... Error report: ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at…
kralco626
  • 8,456
  • 38
  • 112
  • 169
0
votes
3 answers

Getting an Error "ORA-06502: PL/SQL: numeric or value error: character string buffer too small"

I have a below Package which is giving error ORA-06502: PL/SQL: numeric or value error: character string buffer too small Please let me know what is going wrong here. CREATE OR REPLACE PACKAGE BODY PKG_H IS PROCEDURE PROC_SUBMIT_H ( …
Chkusi
  • 139
  • 1
  • 5
  • 15
0
votes
1 answer

Package body: xlsx_builder_pkg / ORA-06502: number or value error: text buffer too small

I use package: xlsx_builder_pkg (export data to excel file from some statement). I added an attachments: xlsx_builder_pkg.pkb xlsx_builder_pkg.pks I try to export all the data from institution table to Excel file with one sheet named country. I…
ziajak
  • 1
  • 1
1
2 3