create or replace trigger tbr before insert
on tb1 for each row
declare a exception;
begin
if :new.tid>100 then
-- raise_application_error(-20000,'abc');
raise a;
end if;
exception
when a then
dbms_output.put('abasdf');end;本人写的如上,直接用raise_application_error(-20000,'abc')插入大于100的数据时在PLSQL DEV中弹出了那个error stack,在前台程序中插入数据时也直接报程序错误!我的想法是如果插入的tid大于100则直接不插入该条记录,也不给任何提示,任何改我的触发器???
on tb1 for each row
declare a exception;
begin
if :new.tid>100 then
-- raise_application_error(-20000,'abc');
raise a;
end if;
exception
when a then
dbms_output.put('abasdf');end;本人写的如上,直接用raise_application_error(-20000,'abc')插入大于100的数据时在PLSQL DEV中弹出了那个error stack,在前台程序中插入数据时也直接报程序错误!我的想法是如果插入的tid大于100则直接不插入该条记录,也不给任何提示,任何改我的触发器???
2 (id number,
3 name varchar2(10));
Table created
SQL>
SQL> create view tb1 as
2 select id ,name from tb2;
View created
SQL>
SQL> create or replace trigger tri_tb1
2 instead of insert on tb1
3 for each row
4 declare
5 -- local variables here
6 begin
7 if :new.id<=100 then
8 insert into tb2(id,name)
9 values(:new.id,:new.name);
10 end if;
11 end;
12 /
Trigger created
SQL> insert into tb1 values(1,'a');
1 row inserted
SQL> select * from tb1;
ID NAME
---------- ----------
1 a
SQL> insert into tb1 values(1000,'b');
1 row inserted
SQL> select * from tb1;
ID NAME
---------- ----------
1 a
SQL>