Encrement Sequence

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Post Reply
jerry-sc
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 45
Joined: Tue, 01 Nov 2011 1:24 pm

Hello everyone,

I need to develop a procedure, which will need to use the next value of a sequence. Someone knows how to do this via SQL for:
1) Catch the NextVal of Sequence
2) Increase the value of sequence to

Thanks!
User avatar
tiago_pimenta
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 213
Joined: Wed, 29 Jun 2011 9:49 am
Location: Barretos / SP

Creates a sequence.

and then to pick up, just use the Select below.

Select all

select sequence.nextval into sua_variavel from dual
Every time you run the SELECT above, it increments if Sequence.
User avatar
vitellozzi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 50
Joined: Wed, 15 Sep 2010 9:53 am
Location: Itatiba

Creating and increasing Sequence:

Creating an initial sequence 1:

Select all

CREATE SEQUENCE SEQ_TESTE START WITH 1;
Next value of a sequence:

Select all

SELECT SEQ_TESTE.NEXTVAL FROM DUAL;
[[99 ]
Excluding sequence:

Select all

DROP SEQUENCE SEQ_TESTE;
Creating a sequence starting from 100

Select all

CREATE SEQUENCE SEQ_TESTE START WITH 100;
Changing the value maximum sequence and increasing:

Select all

ALTER SEQUENCE SEQ_TESTE MAXVALUE 99999 INCREMENT BY 1 NOCYCLE NOCACHE;
no longer,

Daniel Vitellozzi
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests