-1

在将数据插入表之前,如何在存储过程中删除表?

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;
4

2 回答 2

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;
于 2013-01-21T15:49:53.010 回答
1

不需要*in 删除 : delete from table1。另外,如果要删除所有记录,请考虑truncate(但是,truncate是ddl命令,因此您将无法回滚)

于 2013-01-21T15:34:58.730 回答