Solved

Can Before Trigger cancel the insert, update, delete opations?

Posted on 2006-06-28
1
6,662 Views
Last Modified: 2009-05-20
hello

Can Before Trigger cancel the insert, update, delete opations.
Please help me!

CREATE OR REPLACE TRIGGER fnsonld.emp_flds
   BEFORE UPDATE
   ON fnsonld.emp_flds
   FOR EACH ROW
DECLARE
   PRAGMA AUTONOMOUS_TRANSACTION;
   fld_data_type varchar2(50);
BEGIN
      
   IF :OLD.FLDTYPE <> :NEW.FLDTYPE then
  --Cancel update
  end if;

EXCEPTION
   WHEN OTHERS
   THEN
      -- Consider logging the error and then re-raise
      RAISE;
END;
/
0
Comment
Question by:jambuul
1 Comment
 
LVL 2

Accepted Solution

by:
KJlt earned 125 total points
ID: 16999420
Solution 1:

IF :OLD.FLDTYPE <> :NEW.FLDTYPE then
  -- if you need to get error message
  raise_application_error(-20001,'Insert canseled');
end if;

Solution 2:

IF :OLD.FLDTYPE <> :NEW.FLDTYPE then
  -- if you need "silent cancel"
  -- work only on before update triggers, as in your case
  :NEW.FIELD1:=:OLD.FIELD1;
  :NEW.FIELD2:=:OLD.FIELD2;
  -- ... all the table fields
  :NEW.FIELDn:=:OLD.FIELDn;
end if;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now