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: Generating unique key numbers

Re: Generating unique key numbers

From: Tina Tran <tinat_at_sonica.com>
Date: 1997/12/01
Message-ID: <01bcfe8c$abfa37b0$2aaeb6cc@dino>#1/1

Try this:

CREATE TRIGGER tabtrig
 BEFORE INSERT ON tab
FOR EACH ROW
DECLARE
     iNo integer;
BEGIN
     select tabseq.nextval into iNo from dual;    :NEW.id := iNo;
 END;
/

Michal Motalík <cross_at_zl.inext.cz> wrote in article <01bcfcdc$3a121700$LocalHost_at_michal>...
> I am developing a client/server project which will run on both 
> Interbase and Oracle. I wrote a trigger which sets unique numbers 
> from generator to primary index column on Interbase. I want to 
> write similar trigger on Oracle but i have a problem.
>
> I can not create trigger:
>
> CREATE TRIGGER tabtrig
> BEFORE INSERT ON tab
> FOR EACH ROW
> BEGIN
>   :NEW.id := tabseq.NEXTVAL;
> END;
>
> The sequence "tabseq" was created.
> I get the error PLS-00357.
> (reference to sequence is not permitted in these context)
>
> Does anybody know where the problem is?
>                   
> Michal Motalík
> cross_at_zl.inext.cz
>
  Received on Mon Dec 01 1997 - 00:00:00 CST

Original text of this message

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