Subject Re: [IBO] RefreshRows, RefreshKeys
Author Helen Borrie
At 09:34 AM 6/04/2004 +0200, you wrote:
>Hi everyone!
>
>IBO4.2 (registered), FB1.5RC8
>
>Can you tell me why this doesn't work correctly?
>
>(pseudocode)
>
>while (records to insert) do begin
> Table1.Last;
> new_key := Table1.FieldByName(KEYFIELD).AsInteger + 1;
> Table1.InsertRecord([new_key, ...]);
>end; {while}
>
>
>If I don't insert this two additional commands before the "end; {while}"
>statement
>
>Table1.RefreshRows;
>Table1.RefreshKeys;
>
>I obtain the same new_key values for several ongoing records. The DB is in
>ForcedWrites mode, Table1.AutoCommit = True;
>
>(note: Actually this piece of code would generate a Key violation, but it is
>slightly different in the real code, there are checks for existing records
>also, but this illustrates the process that is performed...)
>
>
>Can you help? Should I probably use RefreshRows, RefreshKeys in
>AfterPost/Insert/Delete to be sure I always read the actual dataset
>contents?

Really, you shouldn't be using a technique like this with a client/server
database at all:
a) it should be done on the server
b) the keys should not be dependendent on one another's values

Helen