Re: problem with a trigger

From: Guido Konsolke <GK_at_oblivion.com>
Date: Wed, 10 Dec 2003 09:52:19 +0100
Message-ID: <1071045434.204269_at_news.thyssen.com>


Hi BlackEagle (disgusting!),
commets embedded...

"BlackEagle" wrote...
> Hi everyone,
> I have a table reservations with user-id, date... in it.
> Now I found a trigger to prevent people make changes on table
reservations
> on sunday and any day before 7 am and after 23 pm.
> it looks like this but I keep get an error like "trigger built with
> compilation failure"
> what can I do to resolve this?

Let the rdbms show you the errors...

>
> CREATE TRIGGER reservations_restriction
> BEFORE
> DELETE OR INSERT OR UPDATE
> ON reservations
>
> BEGIN
> IF TO_CHAR(SYSDATE, 'DY') = 'sun')

-------------------------------------------------^


> THEN raise_application_error( -20501,
> ' blah blah blah');
> END IF;
(snip)
>
> and another question, in table reservations, I want to prevent
people make
> reservations for sundays. because the business is closed that day.
> what can I add in the trigger for that, or what kind of check
constraint can
> I use instead.

Since the check constraint is limited in what you can use within, I would add procedural logic to your trigger. Catch the start and end date
and do some maths (hints: day of week, subtraction, addition).

>
> ps. don't know if it does a matter but I'm using oracle 9i on xp
> to connect to the db username/pwd _at_oradb

It's always good and sometimes essential to know...

>
> thanx in advance...

hth,
Guido Received on Wed Dec 10 2003 - 09:52:19 CET

Original text of this message