Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2012

    Unanswered: How to create trigger BEFORE with additional conditions

    Hi Experts,

    I have got a small problem with my PostgreSQL database.

    I would like to create trigger which will be invoking BEFORE any INSERT but with additional parameters - that is what I mean:

    IF I do an INSERT INTO TABLE_1 I want to use TRIGGER in this way {...}
    IF I do an INSERT INTO TABLE_2 I want to use TRIGGER in that way {...}
    etc etc

    Moreover, in all of these TRIGGERs I want to check a condition and if it is has not met I do not want to do INSERT.

    Could you give me any solution?

    Thank you in advance

  2. #2
    Join Date
    May 2008
    If you have different logic for different tables, create separate triggers.

    You can skip a BEFORE trigger by returning NULL as the result.
    PostgreSQL: Documentation: 9.2: Overview of Trigger Behavior
    Last edited by futurity; 09-14-12 at 13:16.

Tags for this Thread

Posting Permissions

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