Re: Dynamically settting sequence start values?

From: <peacocda_at_wwwinc.com>
Date: Tue, 08 Dec 1998 14:19:59 GMT
Message-ID: <74jcid$r3t$1_at_nnrp1.dejanews.com>


You can set it with the START WITH clause of the CREATE SEQUENCE command. What you will probably need to do is used the DBMS_SQL package to dynamically create the CREATE SEQUENCE statement. For instance:

BEGIN
  SELECT SOME_COLUMNE INTO V_SEQVAL
  FROM SOME_TABLE
  WHERE <SOME_CONDITION>; // This is your select statement you referenced

  V_SQLTXT := 'CREATE SEQUENCE MY_SEQUENCE START WITH '||TO_CHAR(V_SEQVAL);   V_CURSOR_HANDLE := DBMS_SQL.OPEN_CURSOR;

  DBMS_SQL.PARSE(V_CURSOR_HANDLE,V_SQLTXT,dbms_sql.v7);
  DBMS_SQL.EXECUTE(V_CURSOR_HANDLE);
  DMBS_SQL.CLOSE_CURSOR(V_CURSOR_HANDLE);
END; This will get you what you need, I hope.

Dan Peacock
DBA
Wolverine World Wide, Inc.

In article <oaFa2.18589$Yy5.16327659_at_news2.voicenet.com>,   "Michael Spoonauer" <spoonau_at_voicenet.com> wrote:
> Does anyone know if it is possible to set the starting value for a sequence
> I am about to drop and recreate based on the returned value from a select
> statement against a table or group of tables?
>
> I'm in Oracle 7.3.x.
>
> Thanks,
> Mike Spoonauer
>
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Dec 08 1998 - 15:19:59 CET

Original text of this message