How to get max sequence number when some record exists in data base table
1001979Apr 18 2013 — edited Apr 18 2013Hi,
I need to create sequence such a way that it should starts from max value already exists in table.
Example:
I have table like below:
ID NAME
1 A
2 B
3 C
4 D
Now when creating sequence it should start from 5 but I should't hard code STARTS WITH 5 in the create sequence. Is there any way to do this without hard code the max value in the sequence. It should automatically take the max + 1 value for next data when I insert.
CREATE SEQUENCE TEST_SEQ.NEXTVAL
START WITH [Max + 1 val from the table]
MAXVALUE 9999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
Thanks.....
Edited by: 998976 on Apr 18, 2013 4:37 AM
Edited by: 998976 on Apr 18, 2013 4:38 AM