Solved

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

Posted on 2006-06-28
1
6,669 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

737 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