Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Trigger syntax
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