genVal := ZSequence1.GetCurrentValue;
But when I close the database and open another database the generator value is from the prior database.
![Sad :(](./images/smilies/icon_sad.gif)
Workaround is not to use TZSequence, but to read the generator value from the Firebird system table with a query. TZQuery does work properly. This is basically what the TZSequence component does internally.
Code: Select all
with queryGen do
begin
SQL.Clear;
SQL.Add('select gen_id(book_gen, 0) as gen ');
SQL.Add('from rdb$database ');
Open;
if RecordCount > 0 then
begin
First;
genVal := FieldValues['gen'];
end; {if}
Close;
end; {with}
I use
Win XP Pro SP2
Delphi 7
Firebird 2.0 RC2
ZeosDBO 6.5.1 cvs - oct 13th 2005.
Attached is a test program ‘gentest’ which shows the error and the workaround.
Required: 2 Firebird database files, each database contains the same generator, but with different values.
For the test program I have used: database: db1.fdb and db2.fdb; generator: gen