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: Trigger syntax

Re: Trigger syntax

From: Gregory J. Pucka <puckag_at_sprintmail.com>
Date: 1997/01/31
Message-ID: <32F2B33C.133@sprintmail.com>#1/1

David Vodnansky wrote:
>
> Hi all,
>
> I have problems with trigger syntax in Oracle (I usually use Interbase).
> Simple example :
>
> create table adresy (id number(3,0),text varchar2(25));
> create sequence gen_adresaid ......;
>
> CREATE TRIGGER gen_adr_id
> BEFORE INSERT ON ADRESY
> FOR EACH ROW
> BEGIN
> new.id:=gen_adresaid.nextval; <--- this line is wrong, why ?
> end;
>
> Thanks for advice.
>
> -------------------
> David Vodnansky
> ICL Czech republic
> vodnansky_at_icl.cz
> -------------------

They are almost right. How about

   Create Trigger Gen_Adr_Id

     Before Insert On Adresy
     For Each Row
     Begin
        Select Gen_Adresaid.NextVal
        :new.id
        From Dual;
     End;

One other thing. Any version of Oracle below 7.3 does not maintain the triggers in the Shared SQL area of the Library Cache. This requires each trigger to be reparse every time it gets executed. Can be time consuming.

Greg Pucka
Management Consultant, TUSC
puckag_at_tusc.com Received on Fri Jan 31 1997 - 00:00:00 CST

Original text of this message

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