Implementing IProviderSupport functions

Implementing IProviderSupport functions

Post by Brian Whea » Tue, 13 Jul 2004 21:36:38


When I tried using FlashFiler 2.13 with DataSnap I discovered that the
client application could display the data but could not apply the changes
back to the FF2 table. Originally I thought that this was because FF2 would
not return a live data set, but I've since found that this is actually
because the IProviderSupport functions were not implemented. Therefore, I am
implementing the IProviderSupport functions using the BDE components as a
base model.

I've implemented the following functions in the TffDataSet base class:

{ --------- IProviderSupport --------- }
procedure PSEndTransaction(Commit: Boolean); override;
function PSExecuteStatement(const ASQL: string; AParams: TParams;
ResultSet: Pointer = nil): Integer; override;
procedure PSGetAttributes(List: TList); override;
function PSGetQuoteChar: string; override;
function PSInTransaction: Boolean; override;
function PSIsSQLBased: Boolean; override;
procedure PSStartTransaction; override;
function PSUpdateRecord(UpdateKind: TUpdateKind; Delta: TDataSet):
Boolean; override;
{ --------- IProviderSupport --------- }

And the following functions in the TffQuery class:

{ --------- IProviderSupport --------- }
procedure PSExecute; override;
function PSGetDefaultOrder: TIndexDef; override;
function PSGetParams: TParams; override;
function PSGetTableName: string; override;
procedure PSSetCommandText(const CommandText: string); override;
procedure PSSetParams(AParams: TParams); override;
{ --------- IProviderSupport --------- }

With these methods implemented the DataSnap client is now able to update the
FF2 table.

The questions that I have are in regard to the ResultSet parameter of the
PSExecuteStatement method. According to the Delphi help file this is to
allow the PSExecuteStatement method to return the results of a SELECT

1. Under what conditions will DataSnap send a SELECT statement to the
PSExecuteStatement method?
2. Assuming that I'm dynamically creating a TffQuery (filling in the
SessionName, DatabaseName, SQL, and Params properties), how would I return
this query using the ResultSet pointer?
3. The Delphi help file states that the caller is responsible for freeing
the data set. Am I correct in that I do not have to keep track of the
dynamically created TffQuery since it will be freed by the caller when it is
no longer needed?

I would appreciate any insight that you can offer!

Brian Wheatley

Implementing IProviderSupport functions

Post by Borla » Thu, 15 Jul 2004 03:23:41

> 1. Under what conditions will DataSnap send a SELECT statement to the

If there is an error during the update, the resolver will generate a select
query to try and get the current/conflicting values for that row. There may
be other cases too, but that's one I know of for sure.

Just return a pointer too it. Take a look at the implementation in
DBTables.pas it uses code like this to create and assign it:

TDataSet(ResultSet^) := TDBDataSet.Create(nil);

Yours should be similar.