Subject | Re: [ib-support] How Set Generator from Select MAX(keyrow) from MyTable |
---|---|
Author | Jason Chapman (JAC2) |
Post date | 2002-03-08T14:30:53Z |
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.
""enricorav"" <enricorav@...> wrote in message
news:a6a64m+dhtn@......
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.
""enricorav"" <enricorav@...> wrote in message
news:a6a64m+dhtn@......
> 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?
>