dbTalk Databases Forums  

how to refresh a sequence

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss how to refresh a sequence in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Robert Wehofer
 
Posts: n/a

Default how to refresh a sequence - 02-23-2005 , 02:51 AM






How could I refresh a sequence in Oracle using an SQL statement?

I've got the problem, that the current number of a sequence is less the
highest index in a table, where I want to use the sequence.

Regards,
Robert



Reply With Quote
  #2  
Old   
Rauf Sarwar
 
Posts: n/a

Default Re: how to refresh a sequence - 02-23-2005 , 03:49 AM







Robert Wehofer wrote:
Quote:
How could I refresh a sequence in Oracle using an SQL statement?

I've got the problem, that the current number of a sequence is less
the
highest index in a table, where I want to use the sequence.

Regards,
Robert
Either drop and recreate OR

declare
max_value_ number := <max value to increment to>;
currval_ number;
nextval_ number;
begin
loop
select your_seq.currval into currval_ from dual;
if (currval_ >= max_value_) then
exit;
else
select your_seq.nextval into nextval_ from dual;
end if;
end loop;
end;
/

Regards
/Rauf



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.