oracle错误过程pl sql
我必须编写一个程序,可以在以下条件下向表中添加行:oracle错误过程pl sql,oracle,stored-procedures,plsql,compiler-errors,Oracle,Stored Procedures,Plsql,Compiler Errors,我必须编写一个程序,可以在以下条件下向表中添加行:noli,noco和notr是其他表中的键,因此我必须确保它们已经存在。所以我写了这个解决方案。程序编译正确,但当我尝试它时,它给我错误对象无效 create or replace procedure insertAffectation ( noli2 affectation.noli%type , date_voy2 affectation.date_voy%type , noco2 affectation.noco%t
noli
,noco
和notr
是其他表中的键,因此我必须确保它们已经存在。所以我写了这个解决方案。程序编译正确,但当我尝试它时,它给我错误对象无效
create or replace procedure insertAffectation
( noli2 affectation.noli%type
, date_voy2 affectation.date_voy%type
, noco2 affectation.noco%type
, notr2 affectation%type )
is
v_noli liaison.noli%type;
v_date affectation.date_voy%type;
v_noco conducteur.noco%type;
v_notr train.notr%type;
begin
begin
select noli into v_noli from liaison where noli=noli2 ;
exception
when NO_DATA_FOUND then raise_application_error('-20000','noli does not exist');
end;
begin
select noco into v_noco from conducteur where noco=noco2;
exception
when NO_DATA_FOUND then raise_application_error('-20004', ' noco does not exist');
end;
begin
select notr from train where notr=notr2;
exception
when NO_DATA_FOUND then raise_application_error('-20001', 'notr does not exist');
end;
select embauche into var_date from conducteur where noco=noco2;
insert into affectation values(notr2,date_voy2,null,noco2,notr2);
end insertAffectation;
错误输出为:
execute insertAffectation('111254',TO_DATE('01/07/02','DD/MM/YY'),'5555','6666')
Error report -
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.INSERTAFFECTATION is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
解决此Oracle错误的选项是:
select embauche into **var_date** from conducteur where noco=noco2;
但是你没有声明var_日期,你声明v_日期。更改它,ORA可能已经解决。您能否显示矫揉造作的表定义,特别是针对所使用的3%类型
affectation.noli%type,affectation.date\u voy%type,affectation.noco%type,
以及参数上的affectation%type是什么?我没有看到该列。我错过了它的装模作样。notr%typetable影响:noli(字符(6)),date\u voy(日期),nbpass(数字(3)可以为空),noco(字符(4))notr(字符(4))如果第三个参数是一个数字,并且您要将其作为字符传入<代码>'5555'可能是类型转换失败。如果再加上类型上缺少的字段,您的过程显然没有成功编译-在您使用的工具中打开它,您将看到确切的错误。您将注意到这一行中的错误:“从notr=notr2的列车中选择notr;”你在这里缺了一个从句。