Home » SQL & PL/SQL » SQL & PL/SQL » Syntax for updating sequences
Syntax for updating sequences [message #22915] Wed, 06 November 2002 03:10 Go to next message
rajesh
Messages: 173
Registered: November 1998
Senior Member
is it possible to update sequences with an ordinary sql command?
Like for instance i have a sequence named seq1. It's current value is 250. I want to set it to 500. How do i do it?
Please reply to my email id
Thanks
Re: Syntax for updating sequences [message #22918 is a reply to message #22915] Wed, 06 November 2002 05:59 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
I dont this there is an direct update or ALTER SEQUENCE.
How about this workaround?
SQL> create sequence test_seq
  2  start with 1 
  3  increment by 1;

Sequence created.

SQL> ed
Wrote file afiedt.buf

  1* select test_seq.nextval from dual
SQL> /.

   NEXTVAL
----------
         1

SQL> /

   NEXTVAL
----------
         2

SQL> select test_seq.currval from dual;

   CURRVAL
----------
         2

SQL> ed
Wrote file afiedt.buf

  1  declare
  2  dumm number;
  3  begin
  4  for mag in 1..240 loop
  5    select test_seq.nextval into dumm from dual ;
  6  end loop;
  7* end;
SQL> /

PL/SQL procedure successfully completed.

SQL> select  test_seq.currval from dual;

   CURRVAL
----------
       242

Re: Syntax for updating sequences [message #22922 is a reply to message #22915] Wed, 06 November 2002 09:51 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
.

Previous Topic: Using SQL variables in PL/SQL
Next Topic: Lock on a row
Goto Forum:
  


Current Time: Wed May 08 19:53:42 CDT 2024