PL / SQL存储过程

时间:2016-08-19 10:14:31

标签: plsql

我想使用存储过程基于id删除表中的记录。 Id值必须作为参数传递。但是在尝试此代码时,表中的数据不会被删除。任何人都可以帮助我完成这个

 create or replace procedure PROC_INV_DELETE(num in number)
 is
begin

  delete from table_name
  where id = '&num';
  commit;

end;
/

1 个答案:

答案 0 :(得分:1)

这可以帮到你的工作:

create or replace procedure PROC_INV_DELETE(num in number)
 is
begin

  delete from table_name
  where id = num; ---No need to use & and '' here
  commit;

end;
/

通话:

declare

a number:= '&num' ; 

Begin

  PROC_INV_DELETE(a); 

end;
/
Enter value for num: 4
old   3: a number:= '&num' ;
new   3: a number:= '4' ;

PL/SQL procedure successfully completed.