Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Sequence to Variable

Status
Not open for further replies.

kizziebutler

Programmer
Apr 28, 2005
81
GB
Please could some advise how to re-code this changing from a sequence to a variable and add one.

DROP SEQUENCE TRACKINGEXTRACT_SEQ;

CREATE SEQUENCE TRACKINGEXTRACT_SEQ
START WITH 7
INCREMENT BY 1
MINVALUE 1
MAXVALUE 7
CYCLE
NOCACHE
ORDER
;


CURSOR next_seq_crsr IS
select
TRACKINGEXTRACT_SEQ.nextval
FROM dual;
 
In what context do you require a variable? Within SQLPlus or PL/SQL, or some other?

You have already set up the sequence to increment by one, so each time you make a call to it, it will automatically add one.
 
PL/SQL

I have a pl/sql but rather than use sequence I would like to use variables. I know it would be something like this:

IN_CNT NUMBER(5):=0;

IN_CNT:=IN_CNT +1;

 
But Kizzie, how do you plan to perpetuate the most-recent value of the sequence beyond the "life" of your PL/SQL code execution?...or is the life of your "sequence" limited to each execution of your PL/SQL block? If the latter is the case, then what you are referring to is not really a "sequence"...it is simply a "counter" which you are initialising then incrementing.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top