Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create Sequence Number with Select Query

spalato76Feb 13 2012 — edited Nov 5 2012
Hi All,

I would like to create a sequence number in oracle but instead of hard coding the "start with" I want to select the max value of the primary key of a table and add 1 and use this instead:

So what I want is:
CREATE SEQUENCE crg_mrec_seq
MINVALUE 1
MAXVALUE 999999999999999999999999999
START WITH select max(primarykey)+1 from table1
INCREMENT BY 1
CACHE 20;
I'm guessing I need to pass this max value as a variable into the create sequence number but I'm not sure what syntax to use.

Thanks,
Ed
This post has been answered by Frank Kulash on Feb 13 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2012
Added on Feb 13 2012
6 comments
8,180 views