Cancel a delete action in a trigger

Hi,
I would like to know the best way to cancel a delete in a trigger, I want to instead change a Field called Active to 'N'
My application is built on views that exclude records with this flag set to 'N'
I have found the IF DELETING ('id') THEN syntax which should be fine to capture the delete, but what is the best way to then cancel the delete?
Thanks in advance
cl3ft

Hi,
I don't think you can cancel the delete action in the trigger if you want to perform another action afterwards. You can cancel the delete action by raising an exception (e.g. with RAISE_APPLICATION_ERROR(-20001,'No delete allowed') ;)
To cancel the delete action and perform an action afterwards I would suggest to create a view on the table containing all columns. On that view, you can define an INSTEAD OF DELETE trigger. In this trigger, simply update the column and do not perform any delete action. This should do the job for you.
Regards
Stephan

Similar Messages

  • Using a link to trigger a delete action on form page?

    Hello,
    I have been unable to find an explanation about how to do this in the documentation, these forums or the old interakt forums.
    Is it possible to use a link to trigger the delete action on a form page?
    If so how is it done?
    Thanks in advance!

    Sorry Purple.. I know that there is a delete link that triggers the delete transaction on the form page..
    The question was if anybody knew if I am able to use a link to trigger that delete transaction (on the form page), much like a dynamic list has a link that will trigger the delete transaction on the form page.
    I don't want to use a dynamic list in this case though. :)
    Thanks anyways,
    Drew

  • Popup to confirm a "delete" action

    Hello,
    I created a layer that allow you to delete some data in  database. I would like to create a popup that would appears when the user click on delete, and where it would be written something like "are you sure you want to delete this row ?"
    if he would click on "confirm", it would delete. Otherwise, if would on cancel, nothing would happen.
    the problem is I am not able not lauch the delete action only if he clicked on "confirm". Can somebody help me please?
    Thank you
    Regards
    Damien

    @ basheer : thank you very much, now it works.
    @ hema latha : I had the problem, so I used a Timer with a 0.05 time but with a specific guard condition. I have a variable that is initialized at 0. when I click on "delete" in my popup, it set the variable at 1. (When the variable ==1, the Timer is triggered). My system is configured to set the variable at 0 on each refresh. That's the only way I found. Hope it will help.
    Regards,
    And a happy new year !!!

  • How can I retrieve the condition in an update or delete using instead of trigger

    I have 2 tables, on which a view is created. To distinguish the tables within the view trigger, a column "source" had been added in the view creation. I want to be able to delete row(s) in table t1 or table t2 through the view, depending on a condition. The problem is that I don't know how I can get back the delete condition IN the INSTEAD of trigger :
    CREATE TABLE t1(m NUMBER, n VARCHAR2(10), o date);
    CREATE TABLE t2(a NUMBER, b VARCHAR2(10), c date);
    -- The view is created based on the 2 tables.
    CREATE OR REPLACE VIEW vt12 AS
    SELECT 't1' source, m, n, o
    FROM t1
    UNION
    SELECT 't2' source, a, b, c
    FROM t2;
    -- The trigger will fire whenever INSERT is performed on the tables through the view
    create or replace trigger tvt12 instead of insert or delete on vt12
    begin
    if inserting then
    if :new.source = 't1' then
    insert into t1 values (:new.m, :new.n, :new.o);
    else
    -- will insert a default value of -1 for the fourth column "d"
    insert into t2(a,b,c,d) values (:new.m, :new.n, :new.o, -1);
    end if;
    elsif deleting then
    -- We don't know the condition for the deletion, so all rows from the
    -- table from which the current row is coming will be deleted
    if :old.source = 't1' then
    delete t1;
    else
    delete t2;
    end if;
    end if;
    end;
    show error
    insert into vt12 values ('t1',1,'1',sysdate);
    insert into vt12 values ('t2',2,'2',sysdate+1);
    insert into vt12 values ('t1',3,'3',sysdate+2);
    insert into vt12 values ('t2',4,'4',sysdate+3);
    insert into vt12 values ('t1',5,'5',sysdate+4);
    insert into vt12 values ('t2',6,'6',sysdate+5);
    commit;
    select * from vt12;
    select * from t1;
    select * from t2;
    delete vt12 where m = 1;
    commit;
    select * from vt12;
    select * from t1;
    select * from t2;
    When I execute this script, the delete statement seems to recognize that the condition is affecting a row in table t1, and therefore deletes all rows from the table, as specified in the delete statement of the trigger... But, what I want to do is ONLY to delete the row affected by the original condition. So my question is to know how I can get back the original condition for the delete, and still use it in the trigger, that will be executed INSTEAD of the delete statement.. I checked in the doc, and everywhere an example of INSTEAD OF trigger can be found, but it's always and only using an INSTEAD OF INSERT trigger, which doesn't need a condition.
    Can anyone help ?
    null

    I've never faced this case myself, but from the documentation it would seem that the INSTEAD OF DELETE is also a FOR EACH ROW trigger. Therefore, you don't really have to worry about the actual "where" clause of the original "delete" operation: Oracle has it all parsed for you, so you just need to redirect, in turn, each view record being deleted to the appropriate table.
    In extenso: for your
    delete vt12 where m = 1;
    => the INSTEAD OF trigger fires once for all records in vt12 where m=1, and I would guess that you trigger code should look like:
    begin
    delete from t1 where m = :old.m and n = :old.n and o = :old.o;
    delete from t2 where a = :old.m and b = :old.n and c = :old.o;
    end;
    It's a bit of overkill compared to the "where" clause of the original "delete" statement, but it should do the job...
    BTW, if by any luck you do have some primary key on tables t1 and t2 (say: columns o and c respectively), then obviously you can make the thing simpler:
    begin
    delete from t1 where o = :old.o;
    delete from t2 where c = :old.o;
    end;
    HTH - Didier

  • HT204053 How can I have an Apple ID canceled or deleted?

    I have 2 Apple ID's and would like to remove one of them. How can I have an Apple ID canceled or deleted?

    Welcome to the Apple Community.
    You can't.
    Just delete the account from your device and don't use it.

  • Cancel or delete app store purchase

    I accidently purchased iMovies, hit 'Pause', but under Purchases' it only has Resume as an option. I can't Hide or Cancel or Delete, etc...As far as I can determine it will stay in Resume forever? Help please, thanks

    Hey there uquackmeup,
    It sounds like you would like to cancel a paused download in the Mac App store. Check out this info from the article named:
    Mac App Store: Buy, download, and install apps
    http://support.apple.com/kb/PH11493
    To cancel a download in App Store, in the toolbar, click Purchases, find the app in the list, hold down the Option key, and then click Cancel.
    Thank you for using Apple Support Communities.
    Quack Quack,
    Sterling

  • HT5731 how can I cancel or delete a movie i downloaded to my iPhone?  The file is too large and it is hung up during the download process

    How can I cancel or delete a movie I tried to download to my iPhone?  The file is too large and iTunes is hung up during the process of downloading.  I've tried to swipe from right to left but that doesn't produce a delete button....

    Slide your finger across the videos' listing in your iPhone Videos App and tap the red "Delete" button that appears.

  • DELETE FROM myTable IGNORE TRIGGER dont works

    HI,
    based on docs
    ::=
      DELETE ]
    i tried to execute:
    DELETE FROM myTable IGNORE TRIGGER
    but i get the error:
    Error Executing 'DELETE FROM myTable IGNORE TRIGGER' (at 21): Missing keyword:WITH.
    then is true to say that this isnt implemented yeat?
    MaxDB version 7.6.06.10
    best regards
    Clóvis

    Hi Clovis,
    Elke pointed out in one of the former threads that the IGNORE TRIGGER option works inside triggers only.
    It's meant to prevent chained trigger firing.
    She also mentioned that this was not documented yet...
    I guess that explains the issue.
    regards,
    Lars

  • Roll back deleted record in a trigger

    Hi,
    The question is How can i prevent a record that has a certain value from being deleted using a Before trigger?
    i tryed
    If :old.rowid=v then
    roll back;
    end if;
    id does not work .
    Any Help will be appreciated.

    You can neer use a rollback in a trigger. You can just make a
    check on your value and delete it only for those tou want.

  • Xfa.event.cancelAction cancels all subsequent actions

    I have created an expenses form which has a number of mandatory and optional fields.   To ensure no expenses are submitted with a value of 0, I have added a check which sets xfa.event.cancelAction = 1 on the presubmit event of my email submit button.  This works, but the problem is that it seems to cancel all subsequent actions too.  I have tried adding xfa.event.cancelAction = 0; in the postsubmit event, but this does not work.
    Does anyone have any ideas?
    Thanks, Paul

    Hi Paul,
    Put an extra visible button which will be your submit button.
    This "extra" button will do validations and all pre-submission checks.
    Once all checks have passed, then execute a "hidden" email submit button.
    Code Example:
    var formPassedValidations = false;
    <do all your validations here - eg: check if values are not zero>
    if (formPassedValidations == true)
         btnHiddenEmailSubmit.execEvent("click");
    else
         <show validation err message>
    hope this is what you are looking for... have fun!
    Regards,
    Luigi D'Amico
    8 BIT PLATOON
    design develop deploy
    www.8bitplatoon.com

  • How to Implement basic Insert ,Update and delete Actions

    Hi all,
              i want to implement 1)INSERT 2)UPDATE 3)DELETE actions in webdynpro application means i have to add a new record to my R/3 backend and update and delete records from my database
    can anyone tell me how to do these actions
    Regards
    Padma N

    Hi Murtuza ,
                           I have 2 views in my application.In the first view i enterd some purchaseorder number and clicked serarch button.The items regarding that purchaseorder gets populated in the table which is in second view.All the data is in R/3 backend system.
    the code i used to get the details of that particular purchaseorder is
    try {
    wdcontext.currentZ_Matrls_For_Inputlement().modelObiect.execte();
    catch(RFCException e){
    /* Catch the Exception Here */
    Here now i want to delete one record of that particular purchaseorder from the database.So Wat should be the code to delete record from R/3 Model
    Regards
    Padma N

  • How can I customise a default delete action

    Dear's
    In Apex, I have report with edit button. By cliking on edit I can see the edit window with a delete button. I want to restrict this with some checks .
    The delete button should be displayed always.
    I want to utilise the default delete action, I don't want to write a code for deletion.
    On click , if the condition restrict , it should give message and should not delete that record.
    Otherwise the record shoud be deletd.
    Dennis
    Edited by: DJ on Mar 20, 2012 11:41 PM

    Dear trent
    Thanks,
    Actually I wanted use a complex condition, I want to write a funtion returing some value. Based on that I want to show a message or I want to do the delete action. If i am putting some condition for the delete button, if false, the button will not be displayed. This should not happen.
    What you mean by validation here, On which item or which action or where should I put the validation code in my senario.
    Dennis

  • Cancel document deletion  process (tr. va42)

    Hello all,
    Iu2019m trying to  cancel the deletion process of a document ( tr. va 42) in  in a particular case.
    Iu2019ve  tried  to use MV45AFZZ include programs FORM USEREXIT_SAVE_DOCUMENT and USEREXIT_DELETE_DOCUMENT  u2013 I check  all necessary condition but I donu2019t know how to disallow
    to delete document  - massage with type u201CEu201D is  Illegal message.
    How and in what user-exit can I cancel document deletion  process?
    Thanks,
    Tatiana

    Hi!
    Is it suitable for you to use this construction in userexit_delete_document:
    ... some conditions checking..
    message 'U cannot delete this document' type 'W'.
    clear sy-ucomm.
    leave to screen sy-dynnr.

  • How can an invoices be canceled or deleted?

    HI
    How can an invoices be canceled or deleted?

    Hi raj
    You cannot delete an invoice but you can cancel the invoice
    use t.code - VF11 to cancel the invoice
    Reagds
    Srinath

  • Intercept delete action in DataAction

    Hi,
    I use jdev10g preview.
    I put in uix page a sample read-only table.
    I put delete action from my AM.
    I want commit after delete, but how known that's delete action is fired in DataAction ?

    The simplest way would be to chain actions on the pageflow
    Drop a Data Action and drop your Delete custom method from the Data Control Palette onto that. The wire up any input parameters into the paramName[n] set-properties in the Struts-Config
    The Drop another data action and drop the commit operation on that, wire the delete action to the commit action with a success and then the commit will be automatically issued once the delete action has finished.

Maybe you are looking for

  • Lightbox appearing at bottom of screen?

    Hey all, my lightbox is appearing at the bottom of the screen for some reason. It's driving me crazy! First I have my page code copied and right after that I have my lightbox css. Thanks so much for any help. I appreciate it. GALLERY PAGE CODE: <!DOC

  • Defaulting the Sotrage location for all the line items in my sales order

    Hi, I have a scenario to default the storage location automatically in my sales order for all the line items. It is not going to change for a particular sales org. Dist. channel & Division combination. Can you pls. suggest me a solution for this. Tha

  • What's a good hardware set up for a solo musician? USB pedal USB keyboard audio interface MIDI interface?

    I am new to Main Stage. I have not bought any hardware interfaces yet because I don't know what will be the most flexible in the long run. I would be using the Main Stage's innate synths and keyboards, drums, an acoustic/electric guitar, bass, harmon

  • WE21 File port, but I don't want carriage returns

    We need to change the way we are sending some delivery IDocs.  We were using an RFC destination, but now want to create a file first, then copy the IDoc text file to another server.  The problem is, we can't change the map that reads this IDoc data. 

  • College Management System Database

    I'm creating one software for College Management System. In which I'm stuck over in Academic Routine(Time Table) creation module. For time table creation module we need three tables, namely SUBJECT{Subject_id, Subject_name, Department_ID,Year}, DEPAR