Subject Re: [ib-support] Setting a generator to the maximum value of the primary key
Author Helen Borrie
At 02:40 PM 05-10-01 +0100, you wrote:
> > >SET GENERATOR GEN_NEW_AUTHOR_ID TO (SELECT MAX(AUTHOR_ID) FROM AUTHOR);
> > >
> > >I have data that I have migrated from Paradox to InterBase. I am
>currently
> > >writing a script with all the updates that I am making to the data, as I
> > >will have to go through this process again.
>
> > Were the Author records committed before you tried to select
>max(AUTHOR_ID)?
>
>Yeah, the records are all committed. The migration was done separately from
>this work I'm doing now on the data.

Hmm, the doc doesn't say you can't use an expression in SET GENERATOR but it doesn't say that you CAN, either. But I confirm that it won't accept anything but a single integer following the TO keyword. What a pest.

If you want a quickish way to set a lot of generators manually, try using the free IB_SQL utility from the www.ibobjects.com site. Get set up with a Browser window, on the Generators page and a DSQL window - just do your

select max(pk) from atable

in the DSQL page, pick up the output from the Fields page and enter it into the value cell on the Generators grid. It gets updated immediately.

Just an idea..

rgds,
Helen


All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________