Home » SQL & PL/SQL » SQL & PL/SQL » how to prevent Insert in Before Insert trigger???
how to prevent Insert in Before Insert trigger??? [message #251034] |
Thu, 12 July 2007 04:22  |
oralover
Messages: 97 Registered: January 2005
|
Member |
|
|
hi all
a very newbie question
i created a table and now want to create a trigger (Before Insert on Each Row) and prevent Insert/Update in this table on some conditions which not belongs this table means in another table i am checking a Flag if its TRUE then insert/update from ANY APPLICATION including SQL environments/tools. i can block Update but how i can achieve this for Insert. please help.
thanks in advance.
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: how to prevent Insert in Before Insert trigger??? [message #251085 is a reply to message #251034] |
Thu, 12 July 2007 06:40   |
oralover
Messages: 97 Registered: January 2005
|
Member |
|
|
very sorry, i failed to convey...
i mean that if a someone is using as below:
Insert Into t
Values (1);
then will it block this insert??
for some Security i want to prevent a wrong guy to insert / update in that table (from any interface) but do not mention him/her that the operation was blocked, and do not block the data from a right person.
like this???
CREATE OR REPLACE TRIGGER EMP_TRIG
BEFORE INSERT OR UPDATE ON TSDETL
REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
WHEN ((NEW.empno > 99))
DECLARE
incorrect EXCEPTION;
aa boolean;
BEGIN
If :NEW.empno > 99 Then
:NEW.sal := :NEW.sal + (:NEW.sal*5)/100;
Else
raise incorrect;
End If;
Exception
When incorrect Then
raise_application_error(-20101,'Prevent it...');
END;
this is not correct as its inserting rows
once again, i appologize Michel.
[Updated on: Thu, 12 July 2007 06:55] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 04:02:51 CDT 2025
|