Newsgroup: it.comp.lang.delphi
Titolo: Key violation on clientdataset refetch: Bug driver Firebird (dbExpress) or configuration error ?

Hi,
I'm working using Delphi 2005 and one Firebird database, through dbExpress
Technology with Provider and ClientDataset.
I have a DB connection SQLDB, a provider P, a master client-dataset M
and a Nested-details client-dataset D into the master client-dataset:
- SQLDB: TSQLConnection
- P: TDataSetProvider
- M: TClientDataset
- D: TClientDataset
I have set the following properties as well as above:
- P.Options := P.Options + [poFetchDetailsOnDemand]; (then 
poFetchDetailsOnDemand is TRUE)
- M.FetchOnDemand := True;
- M.PacketRecord := 20;
- D.FetchOnDemand := True;
- D.PacketRecord := 1;
Here that what appens:
During the M record fetch from 1 to 20 all work fine,
but when the provider try to fetch the next records (from 21 to 40)
it causes a "key violation" error, because it seems that FIREBIRD
server try to return to PROVIDER newly the same records from 1 to 20
instead that from 21 to 40, as well as if the cursor position after
executing of the first fetch operation on the M clientdataset was missing.
This event (with consequently "key violation" error)
are not appen if I set D.FetchOnDemand := False;
The "key violation" error appens because the provider try to insert into
the client-dataset some existing records also if it is set a primary key
that obviously cannot have duplicates.
The primary key is set through the following property on the related Field:
TField.ProviderFlags := TField.ProviderFlags + [pfInKey].
I believe that this problem is indirectly produced by the need of the 
provider to
fetch the D details records between the first fetch operation (records from 
1 to
20) and the second fetch call (records from 21 to 40) for the M records.
I kindly ask you, hoping that somebody have incountered and resolved this
problem, as can I resolve... I don't know if it is not a dbexpress bug or 
driver firebird bug.
I believe that the problem can be caused by the used firebird driver 
configuraction for
dbexpress technology, so I post you as follow the rilevant settings of the 
SQLDB object:
    SQLDB.DriverName          := 'Interbase';
    SQLDB.GetDriverFunc       := 'getSQLDriverINTERBASE';
    SQLDB.KeepConnection      := True;
    SQLDB.LibraryName         := 'dbexpint.dll';
    SQLDB.LoadParamsOnConnect := False;
    SQLDB.LoginPrompt         := False;
    SQLDB.VendorLib           := 'fbclient.dll';
    SQLDB.Params.Clear;
    SQLDB.Params.Add('BlobSize=-1');
    SQLDB.Params.Add('CommitRetain=False');
    SQLDB.Params.Add('DriverName=Interbase');
    SQLDB.Params.Add('ErrorResourceFile=');
    SQLDB.Params.Add('LocaleCode=0000');
    SQLDB.Params.Add('ServerCharSet=');
    SQLDB.Params.Add('SQLDialect=3');
    SQLDB.Params.Add('Interbase TransIsolation=ReadCommited');
    SQLDB.Params.Add('WaitOnLocks=True');
    SQLDB.Params.Add(Format('Database=%s:%s',['localhost','C:\database.fdb']));
    SQLDB.Params.Add(Format('User_Name=',['sysdba']));
    SQLDB.Params.Add(Format('Password=%s',['masterkey']));
    SQLDB.Params.Add(Format('RoleName=%s',['']));
Thanks to all for the yuor attention.
I'm very apologies for the post length,
and expecially for my orrible english.
;)
Riccardo
-- 
* Immolo - Real Estate Search Engine
* web: 
http://www.immolo.it

Scusate, avevo sbagliato newsgroup
:)
Riccardo
-- 
* Immolo - Motore di ricerca per annunci immobiliari
* web: 
http://www.immolo.it