ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/client/2.5/FB25Attachment.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/2.5/FB25Attachment.pas (file contents):
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC vs.
Revision 56 by tony, Mon Mar 6 10:20:02 2017 UTC

# Line 25 | Line 25
25   *
26   *)
27   unit FB25Attachment;
28 + {$IFDEF MSWINDOWS}
29 + {$DEFINE WINDOWS}
30 + {$ENDIF}
31  
32   {$IFDEF FPC}
33 < {$mode objfpc}{$H+}
33 > {$mode delphi}
34   {$interfaces COM}
35   {$ENDIF}
36  
# Line 35 | Line 38 | interface
38  
39   uses
40    Classes, SysUtils, IB,  FBAttachment, FB25ClientAPI, IBHeader,
41 <  FBParamBlock, FBOutputBlock, FBActivityMonitor, IBExternals;
41 >  FBParamBlock, FBOutputBlock, FBActivityMonitor;
42  
43   type
44    { TFB25Attachment }
# Line 46 | Line 49 | type
49    protected
50      procedure CheckHandle; override;
51    public
52 <    constructor Create(DatabaseName: string; aDPB: IDPB;
52 >    constructor Create(DatabaseName: AnsiString; aDPB: IDPB;
53        RaiseExceptionOnConnectError: boolean);
54 <    constructor CreateDatabase(DatabaseName: string; aDPB: IDPB; RaiseExceptionOnError: boolean); overload;
55 <    constructor CreateDatabase(sql: string; aSQLDialect: integer;
54 >    constructor CreateDatabase(DatabaseName: AnsiString; aDPB: IDPB; RaiseExceptionOnError: boolean); overload;
55 >    constructor CreateDatabase(sql: AnsiString; aSQLDialect: integer;
56        RaiseExceptionOnError: boolean); overload;
57      property Handle: TISC_DB_HANDLE read FHandle;
58  
# Line 61 | Line 64 | type
64      procedure DropDatabase;
65      function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; override;
66      function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion): ITransaction; override;
67 <    procedure ExecImmediate(transaction: ITransaction; sql: string; aSQLDialect: integer); override;
68 <    function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; override;
69 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
67 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer); override;
68 >    function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; override;
69 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
70                         aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; override;
71      function GetEventHandler(Events: TStrings): IEvents; override;
72 <    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: string; BPB: IBPB=nil): IBlob; overload;
72 >    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
73      function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
74      function CreateBlob(transaction: ITransaction; SubType: integer; aCharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
75 <    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
76 <    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; override; overload;
75 >    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
76 >    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload; override;
77  
78 <    function OpenArray(transaction: ITransaction; RelationName, ColumnName: string;
78 >    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString;
79        ArrayID: TISC_QUAD): IArray;
80 <    function CreateArray(transaction: ITransaction; RelationName, ColumnName: string
80 >    function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString
81        ): IArray; overload;
82      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
83 <    function CreateArrayMetaData(SQLType: cardinal; tableName: string; columnName: string;
83 >    function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
84        Scale: integer; size: cardinal;
85        acharSetID: cardinal; dimensions: cardinal; bounds: TArrayBounds
86    ): IArrayMetaData;
87  
88      {Database Information}
89  
90 <    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: string): IBlobMetaData;
91 <    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: string): IArrayMetaData;
90 >    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData;
91 >    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
92      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
93      function GetDBInformation(Request: byte): IDBInformation; overload;
94    end;
# Line 103 | Line 106 | begin
106      IBError(ibxeDatabaseClosed,[nil]);
107   end;
108  
109 < constructor TFB25Attachment.Create(DatabaseName: string; aDPB: IDPB;
109 > constructor TFB25Attachment.Create(DatabaseName: AnsiString; aDPB: IDPB;
110    RaiseExceptionOnConnectError: boolean);
111   begin
112    if aDPB = nil then
# Line 116 | Line 119 | begin
119    Connect;
120   end;
121  
122 < constructor TFB25Attachment.CreateDatabase(DatabaseName: string; aDPB: IDPB;
122 > constructor TFB25Attachment.CreateDatabase(DatabaseName: AnsiString; aDPB: IDPB;
123    RaiseExceptionOnError: boolean);
124 < var sql: string;
124 > var sql: AnsiString;
125      tr_handle: TISC_TR_HANDLE;
126   begin
127    inherited Create(DatabaseName,aDPB,RaiseExceptionOnError);
128    sql := GenerateCreateDatabaseSQL(DatabaseName,aDPB);
129    tr_handle := nil;
130    with Firebird25ClientAPI do
131 <  if (isc_dsql_execute_immediate(StatusVector, @FHandle, @tr_handle, 0, PChar(sql),
131 >  if (isc_dsql_execute_immediate(StatusVector, @FHandle, @tr_handle, 0, PAnsiChar(sql),
132                                    SQLDialect, nil) > 0) and RaiseExceptionOnError then
133      IBDataBaseError;
134    if DPB <> nil then
# Line 136 | Line 139 | begin
139    end;
140   end;
141  
142 < constructor TFB25Attachment.CreateDatabase(sql: string; aSQLDialect: integer;
142 > constructor TFB25Attachment.CreateDatabase(sql: AnsiString; aSQLDialect: integer;
143      RaiseExceptionOnError: boolean);
144   var tr_handle: TISC_TR_HANDLE;
145      info: IDBInformation;
146      ConnectionType: integer;
147 <    SiteName: string;
147 >    SiteName: AnsiString;
148   begin
149    inherited Create('',nil,RaiseExceptionOnError);
150    FSQLDialect := aSQLDialect;
151    tr_handle := nil;
152    with Firebird25ClientAPI do
153    begin
154 <    if (isc_dsql_execute_immediate(StatusVector, @FHandle, @tr_handle, 0, PChar(sql),
154 >    if (isc_dsql_execute_immediate(StatusVector, @FHandle, @tr_handle, 0, PAnsiChar(sql),
155                                    aSQLDialect, nil) > 0) and RaiseExceptionOnError then
156        IBDataBaseError;
157  
# Line 169 | Line 172 | begin
172    if DPB = nil then
173    begin
174      if (isc_attach_database(StatusVector, Length(FDatabaseName),
175 <                        PChar(FDatabaseName), @FHandle, 0, nil) > 0) and FRaiseExceptionOnConnectError then
175 >                        PAnsiChar(FDatabaseName), @FHandle, 0, nil) > 0) and FRaiseExceptionOnConnectError then
176        IBDatabaseError;
177    end
178    else
179    begin
180      if (isc_attach_database(StatusVector, Length(FDatabaseName),
181 <                         PChar(FDatabaseName), @FHandle,
181 >                         PAnsiChar(FDatabaseName), @FHandle,
182                           (DPB as TDPB).getDataLength,
183                           (DPB as TDPB).getBuffer) > 0 ) and FRaiseExceptionOnConnectError then
184        IBDatabaseError;
# Line 240 | Line 243 | begin
243   end;
244  
245   function TFB25Attachment.CreateBlob(transaction: ITransaction; RelationName,
246 <  ColumnName: string; BPB: IBPB): IBlob;
246 >  ColumnName: AnsiString; BPB: IBPB): IBlob;
247   begin
248    CheckHandle;
249    Result := TFB25Blob.Create(self,transaction as TFB25transaction,
# Line 262 | Line 265 | begin
265   end;
266  
267   function TFB25Attachment.OpenBlob(transaction: ITransaction; RelationName,
268 <  ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
268 >  ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
269   begin
270    CheckHandle;
271    Result := TFB25Blob.Create(self,transaction as TFB25transaction,
# Line 277 | Line 280 | begin
280    Result :=  TFB25Blob.Create(self,transaction as TFB25transaction,BlobMetaData,BlobID,BPB);
281   end;
282  
283 < procedure TFB25Attachment.ExecImmediate(transaction: ITransaction; sql: string;
283 > procedure TFB25Attachment.ExecImmediate(transaction: ITransaction; sql: AnsiString;
284    aSQLDialect: integer);
285   var TRHandle: TISC_TR_HANDLE;
286   begin
287    CheckHandle;
288    TRHandle := (Transaction as TFB25Transaction).Handle;
289    with Firebird25ClientAPI do
290 <    if isc_dsql_execute_immediate(StatusVector, @fHandle, @TRHandle, 0,PChar(sql), aSQLDialect, nil) > 0 then
290 >    if isc_dsql_execute_immediate(StatusVector, @fHandle, @TRHandle, 0,PAnsiChar(sql), aSQLDialect, nil) > 0 then
291        IBDatabaseError;
292    SignalActivity;
293   end;
294  
295 < function TFB25Attachment.Prepare(transaction: ITransaction; sql: string;
295 > function TFB25Attachment.Prepare(transaction: ITransaction; sql: AnsiString;
296    aSQLDialect: integer): IStatement;
297   begin
298    CheckHandle;
# Line 297 | Line 300 | begin
300   end;
301  
302   function TFB25Attachment.PrepareWithNamedParameters(transaction: ITransaction;
303 <  sql: string; aSQLDialect: integer; GenerateParamNames: boolean): IStatement;
303 >  sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean): IStatement;
304   begin
305    CheckHandle;
306    Result := TFB25Statement.CreateWithParameterNames(self,transaction,sql,aSQLDialect,
# Line 310 | Line 313 | begin
313    Result := TFB25Events.Create(self,Events);
314   end;
315  
316 < function TFB25Attachment.OpenArray(transaction: ITransaction; RelationName, ColumnName: string;
316 > function TFB25Attachment.OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString;
317    ArrayID: TISC_QUAD): IArray;
318   begin
319    CheckHandle;
# Line 318 | Line 321 | begin
321                      GetArrayMetaData(transaction,RelationName,ColumnName),ArrayID);
322   end;
323  
324 < function TFB25Attachment.CreateArray(transaction: ITransaction; RelationName, ColumnName: string): IArray;
324 > function TFB25Attachment.CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray;
325   begin
326    CheckHandle;
327    Result := TFB25Array.Create(self,transaction as TFB25Transaction,
# Line 333 | Line 336 | begin
336   end;
337  
338   function TFB25Attachment.CreateArrayMetaData(SQLType: cardinal;
339 <  tableName: string; columnName: string; Scale: integer; size: cardinal;
339 >  tableName: AnsiString; columnName: AnsiString; Scale: integer; size: cardinal;
340    acharSetID: cardinal; dimensions: cardinal; bounds: TArrayBounds
341    ): IArrayMetaData;
342   begin
# Line 341 | Line 344 | begin
344   end;
345  
346   function TFB25Attachment.GetBlobMetaData(Transaction: ITransaction; tableName,
347 <  columnName: string): IBlobMetaData;
347 >  columnName: AnsiString): IBlobMetaData;
348   begin
349    CheckHandle;
350    Result := TFB25BlobMetaData.Create(self,Transaction as TFB25Transaction,tableName,columnName);
351   end;
352  
353   function TFB25Attachment.GetArrayMetaData(Transaction: ITransaction; tableName,
354 <  columnName: string): IArrayMetaData;
354 >  columnName: AnsiString): IArrayMetaData;
355   begin
356    CheckHandle;
357    Result := TFB25ArrayMetaData.Create(self,Transaction as TFB25Transaction,tableName,columnName);
# Line 371 | Line 374 | begin
374          ReqBuffer[i] := Requests[i];
375  
376        with Firebird25ClientAPI, Result as TDBInformation do
377 <          if isc_database_info(StatusVector, @(FHandle), Length(Requests), PChar(ReqBuffer),
377 >          if isc_database_info(StatusVector, @(FHandle), Length(Requests), ReqBuffer,
378                                   getBufSize, Buffer) > 0 then
379              IBDataBaseError;
380  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines