Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:35:50+00:00 2026-06-11T04:35:50+00:00

How do I write an Oracle trigger, than when a user deletes a certain

  • 0

How do I write an Oracle trigger, than when a user deletes a certain record, the delete doesnt actually happen, but instead performs an update on those rows and sets the status of the record to ‘D’?

I tried:

create or replace
trigger DELFOUR.T4M_ITEM_ONDELETE
before delete on M_ITEM_H
FOR EACH ROW
BEGIN
  UPDATE
    M_ITEM_H
  SET
    ITEM_STAT = 'D'
  WHERE
    CUST_CODE = 'TEST'
    AND ITEM_CODE = 'GDAY'
  ;

  raise_application_error(-20000,'Cannot delete item');
END;

But I am getting mutating table errors. Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:35:51+00:00Added an answer on June 11, 2026 at 4:35 am

    First of all the trigger you wrote would throw a mutating table error. Technically what you are asking is not possible i.e. delete wouldn’t delete but rather update, unless you raise an exception in the middle which could be an ugly way of doing it. I would think users using some sort of application front end which lets them delete data using a delete button, so you may use an update statement there instead of a delete statement.

    Another option would be to create a log table, where you could insert the record before deleting it from the actual table and then join the log table with the actual table to retrieve deleted records. Something like-

     CRETAE TABLE M_ITEM_H_DEL_LOG as SELECT * FROM M_ITEM_H WHERE 1=2;
    

    And then

    create or replace
    trigger DELFOUR.T4M_ITEM_ONDELETE
    before delete on M_ITEM_H
    FOR EACH ROW
    BEGIN
      INSERT INTO
        M_ITEM_H_DEL_LOG
      VALUES (:old.col1, :old.col2,.....) --col1, col2...are columns in M_ITEM_H
      ;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to write to my Oracle DB the user ID and IP address
In Oracle, you can write a row-level trigger by specifying the FOR EACH ROW
I've installed Oracle XE with APEX, but forgot to write down the URL to
Recently I had to write an oracle function, and the error ora-06575 popped up
I am trying to write an Oracle query for a homework assignment. The assignment
In Oracle PL/SQL I was used to write: SELECT * FROM MY_TABLE WHERE ROWNUM
I want to write a SSIS Package for copying data from oracle to MS
I have an oracle database populated with million records. I am trying to write
I'm using Squirrel SQL with Oracle. I often have to write quick queries for
I have the following setup in Oracle, i.e.: (‘aXYZApple-Au’, ‘aXYZOrange-Au’,’aXYZApple-Readonly’,’aXYZOrange-Write’, ’aXYZApple-Write’, ’aXYZOrange-Read’) What I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.