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
|
|
|
|
Re: how to prevent Insert in Before Insert trigger??? [message #251117 is a reply to message #251034] |
Thu, 12 July 2007 07:28   |
oralover
Messages: 97 Registered: January 2005
|
Member |
|
|
very well noticed, and sorry its my mistake but it compiled without any error... anyway now i am going to implement another solution which is, if condition is FALSE it will insert into another dummy table so it will not display any error message, and it will track the wrong guy/user also.
i much much thankful for the great efforts from you guys, i learned alot from very helpful and really professional people here.
|
|
|
|
|