如何在将数据插入表之前对存储过程中的表执行删除操作?
create or replace procedure proc_test is
begin
delete * from table1
insert into table1
select * from table2
end proc_test;
似乎没有用,语法有什么问题?错误是
ERROR at line 8: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<< close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe
6. select * from table1
7.
8. end proc_test;
答案 0 :(得分:2)
create or replace procedure proc_test is
begin
delete * from table1; --semicolon here
insert into table1
select * from table2; --semicolon here
end proc_test;
答案 1 :(得分:1)
删除时不需要*
:delete from table1
。此外,如果要删除所有记录,请考虑truncate
(但是,truncate
是ddl命令,因此您将无法回滚)