DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: PL/SQL Help

  1. #1
    Join Date
    Jun 2013
    Posts
    1

    PL/SQL Help

    Hello guys Im new to the forum!

    Anyone know how to make a trigger that dont allow delete deparments in the next 3 months?


    Thanks :(

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by Virusble View Post
    Hello guys I'm new to the forum!
    Welcome!

    Quote Originally Posted by Virusble View Post
    Anyone know how to make a trigger that doesn't allow delete departments in the next 3 months?
    Yes. If you want help writing a trigger, you should provide a definition of you table, the date column
    used to prevent deletes. Do you mean prevent deletes three months from now, or do you mean prevent
    deletes for three months after the row has been inserted? You will get significantly more useful information
    if you can describe your question with as much detail as possible.

    You probably want some logic along the lines of this:

    Code:
    IF :OLD.created > ADD_MONTHS(SYSDATE, -3)
    THEN
       raise_application_error( -20001, 'Can not delete record, the data is too new' );
    END IF;
    Now you just need to build a trigger around that logic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width