Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Constraint based on sysdate
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
![]() |
![]() |