How to create SEQUENCE?  (also see t6)


How to create procedure that returns a new sequence value. As an Oracle
newbie I've tried this:

CREATE SEQUENCE VOLGNUMR
  START WITH 1
  INCREMENT BY 1
  NOCYCLE
  CACHE 20
  NOORDER;

CREATE procedure NewVolgNumr( NewKey out number )
is begin
   NewKey := volgnumr.nextval;
end;

but that does'nt work. Any Ideas?



Ans:
Nextval is a pseudo column, which you can only use in a query. So, you should
use

    create procedure ... as
    begin
        select volgnumr.nextval
        into NewKey
        from dual;
    end;

I am not complety sure if select into an out parameter is allowed. If not,
then use an extra variable to store the result and assign this to NewKey.
 

Hosted by www.Geocities.ws

1