Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Conditional Trigger

Re: Conditional Trigger

From: <mowinom_at_hotmail.com>
Date: Tue, 20 Nov 2007 11:37:40 -0800 (PST)
Message-ID: <18029b80-d8d5-4e29-85b8-dc7c2e427c97@s36g2000prg.googlegroups.com>


On 20 Nov, 11:25, Frank van Bortel <frank.van.bor..._at_gmail.com> wrote:
> mowi..._at_hotmail.com wrote:
> > Hello all,
>
> > I have the following task: I have a table with two fields, ISBN
> > (NUMBER 9), TITLE and PERIODICAL_OWNER (NUMBER 9). I am trying to
> > create a trigger that checks on insert, that the ISBN being entered is
> > not already in the table but if it does, it must exist in the
> > PERIODICAL_OWNER column.
>
> > So, if the new ISBN being entered is already in the table, it has to
> > be in the PERIODICAL_OWNER column in order for it to be accepted. I am
> > new to PL/SQL and have tried writing a trigger but it's not working.
> > Here it is:
>
> > IF :New.ISSN = :Old.ISSN And
> > :New.ISSN NOT IN (:Old.Tidsskriftnr_eier) THEN
> > RAISE_APPLICATION_ERROR(-20070, 'ERROR>>' ||
> > ' PERIODICAL:' ||
> > ' For ISSN that already exists in the basen, it' ||
> > ' must exist in periodicald to be accepted.');
> > ELSE
> > :New.ISSN := :New.ISSN;
> > END IF;
>
> > Thank you in advance for your help
>
> > --
> > Me
>
> Ever heard of modeling and normalization?
>
> You have two tables: ISBN is a primary key (which will
> guarantee uniqueness of ISBN numbers) on the first, and
> your second table has Periodical as PK, and a foreign key
> relation to ISBN (mandatory).
>
> Really! second class, before Xmas!
> --
> Regards,
> Frank van Bortel
>
> Top-posting is one way to shut me up...- Skjul sitert tekst -
>
> - Vis sitert tekst -

Thanks Frank, but we are dealing with one table here.

Regards,
Mark (Me) Received on Tue Nov 20 2007 - 13:37:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US