RE: How do we set new value for a SEQUENCE?

From: Ingvar Larsson <ingvar.larsson_at_gil-support.se>
Date: Tue, 22 Feb 2000 22:04:06 GMT
Message-ID: <qJDs4.359$y3.188314624_at_newsb.telia.net>


Hi you helpful people out there!

Many thanks to everybody, it was very helpful. I decided to create a procedure that counts up the sequence counter. It will be called very seldom so I don't care about the performance in this case.

Example)

CREATE SEQUENCE X;
CREATE PROCEDURE XREINIT (NEWVAL IN NUMBER) AS     I NUMBER;
BEGIN
[Quoted]   SELECT X.CURRVAL INTO I FROM dual;
  IF (NEWVAL <= I) THEN

       RETURN;
   END IF;    WHILE I < NEWVAL LOOP

       SELECT X.NEXTVAL INTO I FROM dual;    END LOOP;
END; And when the need to īstep up the sequence counter occurs we simply executes the procedure.

EXECUTE XREINIT(2000); -- Ensures the sequence counter is at least 2000

Once again, many thanks to everybody!
/Ingvar

Ingvar Larsson <ingvar.larsson_at_gil-support.se> skrev i diskussionsgruppsmeddelandet:R7fs4.7403$al3.97821_at_newsc.telia.net...
> We have a sequence counter we wants to give new value for the next
sequence
> value.
>
> Example
>
> SELECT seqcnt.nextval FROM dual; returns 1
>
> Than we executes something like
> ALTER SEQUENCE seqcnt NEXTVAL 20;
>
> and the next
> SELECT seqcnt.nextval FROM dual; returns 20
>
> How do we do this?
>
> /Ingvar
>
>
>
>
Received on Tue Feb 22 2000 - 23:04:06 CET

Original text of this message