Re: Constraint based on sysdate
From: Chris Hamilton <ToneCzar_at_erols.com>
Date: Thu, 22 Jul 1999 12:25:14 GMT
Message-ID: <37970d1f.8192169_at_news.erols.com>
Christopher Hamilton
Oracle DBA -- Wall Street Sports
chris_at_wallstreetsports.com
http://www.wallstreetsports.com/ Received on Thu Jul 22 1999 - 14:25:14 CEST
Date: Thu, 22 Jul 1999 12:25:14 GMT
Message-ID: <37970d1f.8192169_at_news.erols.com>
On Wed, 21 Jul 1999 22:28:49 -0400, "David Sisk" <davesisk_at_ipass.net> wrote:
>Hi Brian:
>
>You can't use a constraint, but you can use a trigger to do it.
>
>CREATE TRIGGER.......
>.......
>SELECT sysdate INTO v_sysdate FROM dual; --Put the sysdate into a variable
>IF date_column != v_sysdate -- Compare the values
> RAISE_APPLICATION_ERROR(-20000, 'You cannot use this date'); --
>Disallow the transaction
>END IF;
>....
>END;
>/
I would make this change to the trigger:
Rather than "SELECT sysdate INTO v_sysdate FROM dual;"
Use "v_sysdate := sysdate;"
You may wish to trunc it to remove minutes/seconds ...
v_sysdate := trunc(sysdate);
No database call either way.
Chris
Christopher Hamilton
Oracle DBA -- Wall Street Sports
chris_at_wallstreetsports.com
http://www.wallstreetsports.com/ Received on Thu Jul 22 1999 - 14:25:14 CEST