我有 oracle 数据库 11gR2,我想用块自动创建一些触发器。当我想在下面运行查询时,我有一个错误。
我的块是:
declare
tablesid number ;
tablenames varchar2(4000);
cursor c1 is
select id , title from hr.tables;
begin
open c1;
loop
fetch c1 into tablesid , tablenames;
CREATE OR REPLACE TRIGGER tablenames||'_before_insert'
before insert
on hr.tablenames
DECLARE
columnid number ;
columnval number ;
columntitle varchar(4000);
cursor c2 is
select id from hr.columns where tableid = tablesid ;
BEGIN
-- open c2 ;
for rec in c2 loop
select title into columntitle from hr.columns where id = rec.id
insert into hr.rowaction(columnid,newvalue,oldvalue,actiondate)
(
select id ,:new.columntitle,:old.columntitle,sysdate
from hr.tabletiltes
where id = rec.id
)
select title into columntitle from hr.columns where id = rec.id;
dbms_output.put_line(columntitle);
end loop;
end;
end loop ;close c1; end;
ORA-06550:第 11 行,第 6 列:PLS-00103:在预期以下情况之一时遇到符号“CREATE”:( begin case declare end exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge 06550. 00000 - "line %s, column %s:\n%s" *原因:通常是 PL/SQL 编译错误。*操作:绑定变量“new”未声明匿名块已完成绑定变量“new”未声明匿名块已完成
谢谢