?
Solved

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

Posted on 2006-06-28
1
Medium Priority
?
6,671 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 375 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

762 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