我想使用存储过程基于id删除表中的记录。 Id值必须作为参数传递。但是在尝试此代码时,表中的数据不会被删除。任何人都可以帮助我完成这个
create or replace procedure PROC_INV_DELETE(num in number)
is
begin
delete from table_name
where id = '&num';
commit;
end;
/
答案 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.