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

Home -> Community -> Usenet -> c.d.o.server -> Re: cancel an insert within the trigger?

Re: cancel an insert within the trigger?

From: <andrewst_at_onetel.com>
Date: 21 Sep 2004 04:39:52 -0700
Message-ID: <1095766792.153996.131530@h37g2000oda.googlegroups.com>


Andre wrote:
> Hello all,
>
> I have created an insert trigger:
> If I do a count on the table and this count results in a 1 or higher
I
> would not insert the record. (of_id is not the primary key)
>
> CREATE OR REPLACE TRIGGER iu_cli BEFORE insert or update on client
> FOR EACH ROW
> BEGIN
> CC number;
> IF INSERTING
> THEN
> select count(*) into CC from client WHERE of_id = :new.of_id;
> If CC > 1 then
> --do not insert?
> ????????????
> end if;
> END IF;
> END;
> /
>
>
> The Question is: Can I do this this way?
> What code to put on the ???? marks?

None. Use a UNIQUE constraint instead, if your intention is as stated (do not allow insert if 1 or more records already exist with same value) rather than as coded (do not allow insert if MORE THAN 1 record already exists with same value). Received on Tue Sep 21 2004 - 06:39:52 CDT

Original text of this message

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