一个pl/sql错误

来源:百度知道 编辑:UC知道 时间:2024/06/30 10:33:26
create or replace procedure pro_jobtest
as
begin
insert into t_history select * from t_current;
commit;
truncate table t_current;
exception
when others
then
dbms_output.put_line('Error!');
rollback;
end;

错误信息:
5/11 PLS-00103: 出现符号 "TABLE"在需要下列之一时: := . ( @ % ; 符号 ":=在 "TABLE" 继续之前已插入。

求助!

truncate操作在存储过程里需要用动态sql语句,直接truncate实现不了

这样改一下就行了

create or replace procedure pro_jobtest
is
v_sql VARCHAR2 (2000);

begin
insert into t_history select * from t_current;
commit;
v_sql:='truncate table t_current';
EXECUTE IMMEDIATE v_sql;
exception
when others
then
dbms_output.put_line('Error!');
rollback;
end;

你是不是学这个的
那不是有说了错在哪了么??