James marcus
James marcus

Reputation: 55

Procedure error ORA-06512

Hello i have an oracle database and i am trying to add a procedure to select driver based on the input however i get this error message

ORA-06502 numeric or value error
ORA-06512: at line 9

create or replace
PROCEDURE "SELECTDRIVE" 
(LicenseNumber in number, FirstNamee out VARCHAR2, LastNamee out VARCHAR2, ContactNumberr out NUMBER)
as
begin

select d.firstname, d.lastname, d.contactnumber 
into   FirstNamee , LastNamee , ContactNumberr
from   Driver d
where d.license = LicenseNumber;
end;

and here is the table that it selects from

LICENSE         NUMBER(10,0)
FIRSTNAME       VARCHAR2(15 BYTE)
LASTNAME        VARCHAR2(15 BYTE)
PHOTO           BLOB
CONTACTNUMBER   NUMBER(11,0)

enter image description here

any idea? Thanks

Upvotes: 1

Views: 11831

Answers (2)

Krzysztof Kaszkowiak
Krzysztof Kaszkowiak

Reputation: 896

Make sure that value of input parameter LicenseNumber does not exceed precision of (10,0). As I understand, you get the error when you call the procedure not when you create it. Capture value of the incoming parameter on the database side.

Upvotes: 1

Littlefoot
Littlefoot

Reputation: 143103

Which line is line 9?

There's nothing wrong in this code, at least when I tried it:

SQL> create table driver (
  2    LICENSE         NUMBER(10,0),
  3    FIRSTNAME       VARCHAR2(15 BYTE),
  4    LASTNAME        VARCHAR2(15 BYTE),
  5    PHOTO           BLOB,
  6    CONTACTNUMBER   NUMBER(11,0));

Table created.

SQL> insert into driver (license, firstname, lastname, contactnumber)
  2    values (1, 'Little', 'Foot', 1234);

1 row created.

SQL> create or replace PROCEDURE SELECTDRIVE
  2    (LicenseNumber in number,
  3     FirstNamee out VARCHAR2,
  4     LastNamee out VARCHAR2,
  5     ContactNumberr out NUMBER)
  6  as
  7  begin
  8    select d.firstname, d.lastname, d.contactnumber
  9      into   FirstNamee , LastNamee , ContactNumberr
 10      from   Driver d
 11      where d.license = LicenseNumber;
 12  end;
 13  /

Procedure created.

SQL> declare
  2    l_fn driver.firstname%type;
  3    l_ln driver.lastname%type;
  4    l_cn driver.contactnumber%type;
  5  begin
  6    selectdrive(1, l_fn, l_ln, l_cn);
  7  end;
  8  /

PL/SQL procedure successfully completed.

SQL>

Please, copy/paste your SQL*Plus session so that we could see what happens.

Upvotes: 0

Related Questions