Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Technique for setting initial counter on Autoinc column
Thu, Nov 30 2006 10:30 AMPermanent Link

David Keith
Is it possible to set the initial counter value - NOT the min value - of an autoinc column
to a specific value
within a CREATE TABLE sql statement?

Thanks.
Thu, Nov 30 2006 11:22 AMPermanent Link

"Robert"

"David Keith" <dkeith@paychex.com> wrote in message
news:5E54FA9D-2F30-4491-A6E6-4E914A5AA63C@news.elevatesoft.com...
> Is it possible to set the initial counter value - NOT the min value - of
> an autoinc column
> to a specific value
> within a CREATE TABLE sql statement?
>

Sure

CREATE TABLE IF NOT EXISTS "t2"
(
  "id" AUTOINC,
  "b" BOOLEAN,
PRIMARY KEY ("id") COMPRESS NONE

LOCALE CODE 0
USER MAJOR VERSION 1
LAST AUTOINC 5
);

There is a bug in DBISAM (I think it is a bug, anyway) which requires the
LAST AUTOINC to be the last statement. You are setting the last value so, in
the example above, the next add will have a 6 in the ID field.

Robert

Thu, Nov 30 2006 11:42 AMPermanent Link

David Keith
Thanks Robert. In my testing I discovered that 'bug' or whatever. But that does work in
the CREATE TABLE statement, if it's at the end as you said.

Thanks again.

"Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote:


"David Keith" <dkeith@paychex.com> wrote in message
news:5E54FA9D-2F30-4491-A6E6-4E914A5AA63C@news.elevatesoft.com...
> Is it possible to set the initial counter value - NOT the min value - of
> an autoinc column
> to a specific value
> within a CREATE TABLE sql statement?
>

Sure

CREATE TABLE IF NOT EXISTS "t2"
(
  "id" AUTOINC,
  "b" BOOLEAN,
PRIMARY KEY ("id") COMPRESS NONE

LOCALE CODE 0
USER MAJOR VERSION 1
LAST AUTOINC 5
);

There is a bug in DBISAM (I think it is a bug, anyway) which requires the
LAST AUTOINC to be the last statement. You are setting the last value so, in
the example above, the next add will have a 6 in the ID field.

Robert

Thu, Nov 30 2006 2:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Robert,

<< There is a bug in DBISAM (I think it is a bug, anyway) which requires the
LAST AUTOINC to be the last statement. You are setting the last value so, in
the example above, the next add will have a 6 in the ID field. >>

It's not a bug - clauses in SQL statements must be specified in a defined
order:

http://www.elevatesoft.com/dbisam4d5_create_table_statement.htm

It would be like allowing this:

SELECT *
ORDER BY Test
FROM MyTable

--
Tim Young
Elevate Software
www.elevatesoft.com

Image