Good afternoon staff.
I would like to take a doubt.
Would you like to create a before trigger delete, for example, and put a clause and if it is true, do not run the delete?
For example:
Before delete trigger, but if A = 1, does it not shoot?
Would that have to come from the application?
grateful,
Trevisolli
: -O
Trigger Before Delete
-
- Rank: Estagiário Sênior
- Posts: 13
- Joined: Tue, 01 Nov 2005 11:53 pm
- Location: São Paulo
- Contact:
You can create this type of rule on trigger yes (bad idea). In my opinion the right place for this is in the application, in logic.
For example of trigger you could:
For example of trigger you could:
ops$marcio@LNX10GR2> create table t ( x int );
Table created.
ops$marcio@LNX10GR2>
ops$marcio@LNX10GR2> create or replace trigger t_bi_fer
2 before insert on t for each row
3 begin
4 if ( :new.x = 1 ) then
5 raise_application_error(-20001, 'Aqui não!');
6 end if;
7 end;
8 /
Trigger created.
ops$marcio@LNX10GR2> show error
No errors.
ops$marcio@LNX10GR2>
ops$marcio@LNX10GR2> insert into t values ( 0 );
1 row created.
ops$marcio@LNX10GR2> insert into t values ( 1 );
insert into t values ( 1 )
*
ERROR at line 1:
ORA-20001: Aqui não!
ORA-06512: at "OPS$MARCIO.T_BI_FER", line 3
ORA-04088: error during execution of trigger 'OPS$MARCIO.T_BI_FER'
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Another way, which may not apply to the Trevisolli case, is to create a view and apply a trigger instead of it.
Hence, within this trigger, you test the condition and apply or not the delete in the original table ...
(of course, in this case it is not Guaranteed the fact that the user apply a delete directly to the table) ... that is, it is not for much ...
Hence, within this trigger, you test the condition and apply or not the delete in the original table ...
(of course, in this case it is not Guaranteed the fact that the user apply a delete directly to the table) ... that is, it is not for much ...
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Are you talking about comparing a field with another (from another table) inside a trigger before delete?
Just do the desired SELECT within the trigger.
Is that it? If it is not, explain better what you want to do.
Just do the desired SELECT within the trigger.
Is that it? If it is not, explain better what you want to do.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 19 guests