#1 mORMot 1 » SynDBVCL feature missing » 2017-08-22 11:30:32

BLADEXP
Replies: 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;

#2 Re: mORMot 1 » Windows FMX Client versus Android FMX Client » 2016-08-16 16:41:18

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;

#3 Re: mORMot 1 » Field size issue DBGrid in 17 - TClientDataset use sample » 2016-07-01 00:10:21

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;
    ..........

Board footer

Powered by FluxBB