Subject Re: Problem calling set generator...
Author phil_hhn
--- In, Lester Caine <lester@...> wrote:
> Alan McDonald wrote:
> >> Hi, (This is Firebird 1.5.3)
> >> I have a routine which copies all rows of the prefs table from one DB
> >> into another (ALL columns, including the pk's).
> >
> > a better idea is to NOT include the PK field in the copy process.
The PK
> > will be re-generated - no need to fiddle any more
> This may not be practical if the pk is being used in other tables, but
> IS the right approach otherwise. I tend to CREATE the generator with
> right value after I've pumped the data, and not create any related
> triggers until the pump process is complete.

You are correct, this is a data pump process (sorry readers, I was
trying to keep the stated problem simple ;-) ). So I am actually
copying multiple tables (and in each the pk's also). The constraints
get added to the destination table after the data pump (so I can rip
thru all the data and not worry about the pk's causing constraint
violations part-way thru).
Good suggestion, I could add the generators afterwards, but am I not
going to hit the same issue when I set the new generator to its
starting value?
Actually, maybe the simplest way to resolve this problem would be to
get the max value as a separate query, then construct the 'set
generator...' with the value hard-coded. But it would be nice to do it
as one statement :)