Subject | Re: How Set Generator from Select MAX(keyrow) from MyTable |
---|---|
Author | enricorav |
Post date | 2002-03-10T01:47:52Z |
Hi,
thank you, your solution work very well.
But i have anohter question, is possible to make the same job with a
SQL Script and not with trigger or stored procedure ?
Best regards,
Enrico Raviglione.
thank you, your solution work very well.
But i have anohter question, is possible to make the same job with a
SQL Script and not with trigger or stored procedure ?
Best regards,
Enrico Raviglione.
--- In ib-support@y..., "Jason Chapman (JAC2)" <jason@j...> wrote:
> the set generator is considered DDL, therefore can not be executed
in a
> trigger, SP.
>
> But if you were sure there were no users adding to the table you
could:
>
> select max(id) from tbl into :curMax
> curGen = gen_id(g,0)
> dummyvar = gen_id(g,curMax-curGen)
> if (gen_id(g,0) <> curMax) then
> Houston we have a problem.
>
> Very dodgy in terms of someone could either add another row to the
table or
> be adding a row at the time you are running this.
>
> In the disaster, have to bring a replicated db up to speed
scenario, do this
> in code:
> If the replicated DB is up to date then we do a whole load of
trigger
> juggling to make it a live DB then
> select max(id) from tbl where id > theLastOneWeChecked (this is
hugely
> faster than just select max(id), can make the difference between 2
mins and
> 2 hours on a very large DB.
> Extract the generators to text file
> merge the two pieces of info and run as a script.
>
> JAC.
>
>
> > Hi,
> > i need to set generator with the MAX value extracted from my
table.
> > Of course this operation are due when no user work on the DB and
are
> > usefull only after an import from the old version of my db.
> >
> > How can i do this?
> >