Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Posts
    18

    Unanswered: Check or a trigger ?

    Hi all,

    I have the following trigger which works fine:

    create or replace trigger tour_tg
    after insert on tour
    for each row
    begin
    if trunc(:new.startdate) <= trunc(sysdate+7) then
    RAISE_APPLICATION_ERROR (
    -20100,'Date should be at least 8 days after todays date');
    END IF;
    if trunc(:new.enddate) < trunc(:new.startdate) then
    RAISE_APPLICATION_ERROR (
    -20100, 'End Date must be After Start Date');
    END IF;
    END;


    What I want to know is whether this could be done as a check constraint rather than a trigger .. so I guess I'm asking what is the actual difference between the two ? I want to know this so I know which one to use in given situations

    Thanks in advance

    Greg

  2. #2
    Join Date
    Feb 2004
    Location
    Dublin, Ireland
    Posts
    212
    Me personally, I'd use constraint check. Trigger is not needed as you don't update/insert anything.

  3. #3
    Join Date
    Dec 2003
    Posts
    1,074
    With the TRIGGER you get to deliver back a customized error message, with RAISE_APPLICATION_ERROR().

    -Chuck

Posting Permissions

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