Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Question: Use Trigger to Prevent Deletes with no Where Clause?
Użytkownik Thomas Kyte napisał:
> In article <1105644268.227713.55120_at_f14g2000cwb.googlegroups.com>, Jesse says...
>
>>Hi all. We recently discovered a bug in one of our applications (it's >>in Visual Basic; we inherited it) that under an obscure set of >>conditions executes a "DELETE FROM [table]" without a where clause. We >>can fix the app, but getting it certified for use takes time; however, >>I can make various administrative changes to the database however >>without approval. >> >>My question is, can I use a "before" trigger to detect the mass "DELETE >>FROM" statement and prevent it from executing? >> >>Thanks. >>Jesse
I can put always-true condition in WHERE clause and i delete all rows. You slow delete if you try to count rows don't you?
What about this:
create or replace trigger t_trigger
after delete on t
declare l_n number; begin select count(*) into l_n from t; if l_n = 0 then raise_application_error( -20000, 'you still totally lose' ); end if;
-- NoelReceived on Fri Jan 14 2005 - 07:00:32 CST