0

I having a table column holds auto increment value. I want to start incrementing from specified vlaue. How can i specify this functionality in slick ddl.

Code i am using for column of table creation in slick is :

def id = column[Long]("id", O.PrimaryKey, O.AutoInc, O.NotNull)

I have come across this article but didn't find exact solution.

create table "COCKTAIL" (
  "ID" BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100000) NOT NULL PRIMARY KEY,
  "NAME" VARCHAR NOT NULL)

Can someone help me how to achieve this.

Rajeev
  • 4,762
  • 8
  • 41
  • 63

1 Answers1

0

What about O.Default(...)? Look at here: ColumnOption.

def id = column[Long]("id", O.PrimaryKey, O.AutoInc, O.NotNull,O.Default(100000))
Steven Dobay
  • 331
  • 2
  • 10
  • I tried that option. It is throwing exception of multiple initialization : ERROR: multiple default values specified for column "id" of table – Rajeev Feb 13 '14 at 14:41
  • Try to remove "O.PrimaryKey"(maybe it set the default value) or use "Default(100000)". – Steven Dobay Feb 13 '14 at 15:04
  • seems Default will give a default value. I don't want it to be default value. I want to increment from that default value. Only first row value should start from there – Rajeev Feb 14 '14 at 06:48
  • Then you should set the value of the first record's id. – Steven Dobay Feb 14 '14 at 08:57
  • After inserting i updated record id to 10000 and then inserted second one.It is still counting from 0. in this case, new inserted record id is one... that is also not working – Rajeev Feb 14 '14 at 09:01