cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to loop SQL "select WTKEY_SEQ.nextval from dual"

flemoine
10-Marble

How to loop SQL "select WTKEY_SEQ.nextval from dual"

Hi guys,

In order to solve a problem of method server start, I have to do the request:

select WTKEY_SEQ.nextval from dual


I have to do it until its value reaches 163553 but now it is only 139082. Each time I do the request, the value increments of 1.


I don't know very much about SQL and I would like to know if there is syntax to make a loop of this request until it reaches the correct value.


Thank you very much.


Regards,

Florent

1 REPLY 1
ChrisSpartz
13-Aquamarine
(To:flemoine)

Rather than looping the statement, it would be easier to just change the increment value for the sequence. The statement to change the increment value is:

Alter sequence WTKEY_SEQ increment by <New Increment Value>;

Just replace '<New Increment Value>' with the difference between the current sequence value and the value you want the sequence to be. After changing the increment value, then you just need to run 'select WTKEY_SEQ.nextval from dual' once, and it will increment to your target value. Afterward, make sure to set the increment value back to 1, by running:
Alter sequence WTKEY_SEQ increment by 1;

Announcements


Top Tags