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: Jurij Modic <jurij.modic_at_mf.sigov.mail.si>
Date: 1997/01/31
Message-ID: <32F1F1BA.488A@mf.sigov.mail.si>#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;

You can not assign a value from a sequence to a variable in PL/SQL, you must use:

     SELECT gen_adresaid.nextval INTO my_variable FROM dual;
     new.id := my_variable.

Regards, Jure

--
 ===============================================================
 ! Jurij Modic                            Republic of Slovenia !
 !  tel: +386 61 178 55 14                Ministry of Finance  !
 !  fax: +386 61  21 45 84                Zupanciceva 3        !
 !  e-mail: jurij.modic_at_mf.sigov.mail.si  Ljubljana 1000       !
 ===============================================================
Received on Fri Jan 31 1997 - 00:00:00 CST

Original text of this message

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