You are not logged in.
Pages: 1
{$ifdef ISDELPHIXE3}
function TSynDBSQLDataSet.PSExecuteStatement(const ASQL: string;
AParams: TParams): Integer;
var DS: TDataSet;
begin
DS := nil;
result := PSExecuteStatement(ASQL,AParams,DS);
DS.Free;
end;
function TSynDBSQLDataSet.PSExecuteStatement(const ASQL: string;
AParams: TParams; var ResultSet: TDataSet): Integer;
{$else}
function TSynDBSQLDataSet.PSExecuteStatement(const ASQL: string;
AParams: TParams; ResultSet: Pointer): Integer;
{$endif}
var Stmt: ISQLDBStatement;
p: integer;
begin // only execute writes in current implementation
if fConnection=nil then
raise ESQLQueryException.CreateUTF8('%.PSExecuteStatement with Connection=nil',[self]);
Stmt := fConnection.NewThreadSafeStatementPrepared(StringToUTF8(ASQL),false);
if Stmt<>nil then
try
if AParams<>nil then
for p := 0 to AParams.Count-1 do
if aParams[p].DataType = ftBlob then <-------------
Stmt.BindBlob(p+1,pointer(aParams[p].AsBlob),length(aParams[p].AsBlob)) <-------------
else Stmt.BindVariant(p+1,AParams[p].Value,false);
Stmt.ExecutePrepared;
result := Stmt.UpdateCount;
if result=0 then
result := 1; // optimistic result, even if SynDB returned 0
except
result := 0;
end else
result := 0;
end;
Boolean values are transmitted to the server:
true = -1
false = 0
function TServiceRemoteSQL.Execute(const aSQL: String; const aExpectResults: Boolean; const aExpanded: Boolean): Variant;
var res: TVariantDynArray;
a,b:integer;
begin
if aExpectResults=True then a:=1 else a:=0;
if aExpanded=True then b:=1 else b:=1;
fClient.CallRemoteService(self,'Execute',1, // raise EServiceException on error
[aSQL,a,b],res);
Result := res[0];
end;
My solution:
TSynBinaryDataSet = class(TSynVirtualDataSet)
protected
fData: RawByteString;
fDataAccess: TSQLDBProxyStatementRandomAccess;
fTemp64: Int64;
fColWSDataSize:TIntegerDynArray;
.....
procedure TSynBinaryDataSet.InternalInitFieldDefs;
var F: integer;
DBType: TFieldType;
NumWS: integer;
begin
NumWS:=0;
FieldDefs.Clear;
if fDataAccess=nil then
exit;
for F := 0 to fDataAccess.ColumnCount-1 do
with fDataAccess.Columns[F] do begin
case ColumnType of
SynCommons.ftInt64: DBType := ftLargeint;
SynCommons.ftDate: DBType := ftDateTime;
SynCommons.ftUTF8:
begin
if length(fColWSDataSize) > 0 then
begin
DBType := ftWideString;
inc(NumWS);
end
else
if ColumnDataSize=0 then
DBType := ftDefaultMemo else DBType := ftWideString; // means UnicodeString for Delphi 2009+
end;
SynCommons.ftBlob: DBType := ftBlob;
SynCommons.ftDouble, SynCommons.ftCurrency: DBType := ftFloat;
else raise EDatabaseError.CreateFmt('GetFieldData ColumnType=%d',[ord(ColumnType)]);
end;
if (DBType = ftWideString) and (length(fColWSDataSize) >= NumWS) then
FieldDefs.Add(UTF8ToString(ColumnName),DBType,fColWSDataSize[NumWS-1]) else
FieldDefs.Add(UTF8ToString(ColumnName),DBType,ColumnDataSize);
end;
end;
TSynDBDataSet = class(TCustomClientDataSet)
protected
fDataSet: TSynDBSQLDataSet;
fProvider: TDataSetProvider;
fIgnoreColumnDataSize: boolean;
function GetConnection: TSQLDBConnectionProperties; virtual;
procedure SetConnection(Value: TSQLDBConnectionProperties); virtual;
// from TDataSet
procedure OpenCursor(InfoQuery: Boolean); override;
{$ifdef ISDELPHI2007ANDUP}
// from IProviderSupport
function PSGetCommandText: string; override;
{$endif}
public
/// initialize the instance
constructor Create(AOwner: TComponent); overload; override;
constructor Create(AOwner: TComponent; ColWSDataSize:TIntegerDynArray); overload;
..........
Pages: 1