1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Trigger after delete

Discussion in 'SQL PL/SQL' started by Puru, Apr 30, 2011.

  1. Puru

    Puru Forum Advisor

    Messages:
    32
    Likes Received:
    1
    Trophy Points:
    90
    Dear all,

    How to write trigger to display msg like 'record deleted succesfully'

    I have a table called emp2 and values are as below;

    EMPNO ENAME SAL
    ---------- ---------- ----------
    1111 Puru 1000
    1111 Puru 1000
    1111 Puru 1000
    1111 Puru 1000
    If I have deleted by using wrong method then it should be shown msg like 'You are using wrong method to delete the record'
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    How did your instructor explain the solution to this problem?
     
  3. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    What do you mean by "wrong method" ? How Oracle knows that yor are using wrong method to delle the record ? And why you want to use the trigger prevent wring deltetion ? Used procedures instead.
     
  4. Puru

    Puru Forum Advisor

    Messages:
    32
    Likes Received:
    1
    Trophy Points:
    90
    My instructor is not covered this topic.
     
  5. Puru

    Puru Forum Advisor

    Messages:
    32
    Likes Received:
    1
    Trophy Points:
    90
    Actually Iam trying to delete the record by using ROWNUM. Suppose if i used rownum=2, then it ll display an error. How to solve this.
     
  6. Sadik

    Sadik Community Moderator Forum Guru

    Messages:
    1,906
    Likes Received:
    252
    Trophy Points:
    1,455
    Show your code then we can suggest.
     
  7. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Read here on why rownum=2 does not work:

    http://oratips-ddf.blogspot.com/2008/06/row-row-row.html

    I wouldn't advise using ROWNUM for any delete process as you really cannot control which row may be assigned rownum 2. ROWID is a constant value for a given row as each rowid is distinct and 'points' to one, and only one, row. As suggested in another post show us your code so someone can provide assistance.