Procedure error ORA-06512

馋奶兔 提交于 2019-12-11 12:16:26

问题


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)

any idea? Thanks


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/50090915/procedure-error-ora-06512

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!