ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBAttachment.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/FBAttachment.pas (file contents):
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 56 by tony, Mon Mar 6 10:20:02 2017 UTC

# Line 25 | Line 25
25   *
26   *)
27   unit FBAttachment;
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 45 | Line 48 | type
48      FDPB: IDPB;
49      FFirebirdAPI: IFirebirdAPI;
50    protected
51 <    FDatabaseName: string;
51 >    FDatabaseName: AnsiString;
52      FRaiseExceptionOnConnectError: boolean;
53      FSQLDialect: integer;
54      FHasDefaultCharSet: boolean;
55      FCharSetID: integer;
56      FCodePage: TSystemCodePage;
57 <    constructor Create(DatabaseName: string; DPB: IDPB;
57 >    constructor Create(DatabaseName: AnsiString; DPB: IDPB;
58        RaiseExceptionOnConnectError: boolean);
59      procedure CheckHandle; virtual; abstract;
60 <    function GenerateCreateDatabaseSQL(DatabaseName: string; aDPB: IDPB): string;
60 >    function GenerateCreateDatabaseSQL(DatabaseName: AnsiString; aDPB: IDPB): AnsiString;
61      procedure EndAllTransactions;
62      procedure SetParameters(SQLParams: ISQLParams; params: array of const);
63    public
# Line 64 | Line 67 | type
67      function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; overload; virtual; abstract;
68      function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion): ITransaction; overload; virtual; abstract;
69      procedure Disconnect(Force: boolean=false); virtual; abstract;
70 <    procedure ExecImmediate(transaction: ITransaction; sql: string; aSQLDialect: integer); overload; virtual; abstract;
71 <    procedure ExecImmediate(TPB: array of byte; sql: string; aSQLDialect: integer); overload;
72 <    procedure ExecImmediate(transaction: ITransaction; sql: string); overload;
73 <    procedure ExecImmediate(TPB: array of byte; sql: string); overload;
74 <    function ExecuteSQL(TPB: array of byte; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
75 <    function ExecuteSQL(transaction: ITransaction; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
76 <    function ExecuteSQL(TPB: array of byte; sql: string; params: array of const): IResults; overload;
77 <    function ExecuteSQL(transaction: ITransaction; sql: string; params: array of const): IResults; overload;
78 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
79 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer;
70 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer); overload; virtual; abstract;
71 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString; aSQLDialect: integer); overload;
72 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload;
73 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload;
74 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
75 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
76 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload;
77 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload;
78 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
79 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
80                               params: array of const): IResultSet; overload;
81 <    function OpenCursor(transaction: ITransaction; sql: string): IResultSet; overload;
82 <    function OpenCursor(transaction: ITransaction; sql: string;
81 >    function OpenCursor(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
82 >    function OpenCursor(transaction: ITransaction; sql: AnsiString;
83                               params: array of const): IResultSet; overload;
84 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
85 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer;
84 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
85 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
86                               params: array of const): IResultSet; overload;
87 <    function OpenCursorAtStart(transaction: ITransaction; sql: string): IResultSet; overload;
88 <    function OpenCursorAtStart(transaction: ITransaction; sql: string;
87 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
88 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString;
89                               params: array of const): IResultSet; overload;
90 <    function OpenCursorAtStart(sql: string): IResultSet; overload;
91 <    function OpenCursorAtStart(sql: string;
90 >    function OpenCursorAtStart(sql: AnsiString): IResultSet; overload;
91 >    function OpenCursorAtStart(sql: AnsiString;
92                               params: array of const): IResultSet; overload;
93 <    function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; overload; virtual; abstract;
94 <    function Prepare(transaction: ITransaction; sql: string): IStatement; overload;
95 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
93 >    function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload; virtual; abstract;
94 >    function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload;
95 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
96                         aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload; virtual; abstract;
97 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
97 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
98                         GenerateParamNames: boolean=false): IStatement; overload;
99      function GetEventHandler(Events: TStrings): IEvents; overload; virtual; abstract;
100 <    function GetEventHandler(Event: string): IEvents; overload;
100 >    function GetEventHandler(Event: AnsiString): IEvents; overload;
101  
102      function GetSQLDialect: integer;
103 <    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; virtual; abstract; overload;
103 >    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload; virtual; abstract;
104      function OpenBlob(transaction: ITransaction; Field: ISQLData; BPB: IBPB=nil): IBlob; overload;
105      property SQLDialect: integer read FSQLDialect;
106      property HasDefaultCharSet: boolean read FHasDefaultCharSet;
# Line 112 | Line 115 | uses FBMessages, FBTransaction;
115  
116   { TFBAttachment }
117  
118 < constructor TFBAttachment.Create(DatabaseName: string; DPB: IDPB;
118 > constructor TFBAttachment.Create(DatabaseName: AnsiString; DPB: IDPB;
119    RaiseExceptionOnConnectError: boolean);
120   begin
121    inherited Create;
# Line 123 | Line 126 | begin
126    FRaiseExceptionOnConnectError := RaiseExceptionOnConnectError;
127   end;
128  
129 < function TFBAttachment.GenerateCreateDatabaseSQL(DatabaseName: string;  aDPB: IDPB): string;
130 < var CreateParams: string;
129 > function TFBAttachment.GenerateCreateDatabaseSQL(DatabaseName: AnsiString;  aDPB: IDPB): AnsiString;
130 > var CreateParams: AnsiString;
131      DPBItem: IDPBItem;
132   begin
133    CreateParams := '';
# Line 133 | Line 136 | begin
136    begin
137      DPBItem :=  aDPB.Find(isc_dpb_user_name);
138      if DPBItem <> nil then
139 <      CreateParams += ' USER ''' + DPBItem.AsString + '''';
139 >      CreateParams := CreateParams + ' USER ''' + DPBItem.AsString + '''';
140  
141      DPBItem :=  aDPB.Find(isc_dpb_password);
142      if DPBItem <> nil then
143 <      CreateParams += ' Password ''' + DPBItem.AsString + '''';
143 >      CreateParams := CreateParams + ' Password ''' + DPBItem.AsString + '''';
144  
145      DPBItem :=  aDPB.Find(isc_dpb_page_size);
146      if DPBItem <> nil then
147 <      CreateParams += ' PAGE_SIZE ' + DPBItem.AsString;
147 >      CreateParams := CreateParams + ' PAGE_SIZE ' + DPBItem.AsString;
148  
149      DPBItem :=  aDPB.Find(isc_dpb_lc_ctype);
150      if DPBItem <> nil then
151 <      CreateParams += ' DEFAULT CHARACTER SET ' + DPBItem.AsString;
151 >      CreateParams := CreateParams + ' DEFAULT CHARACTER SET ' + DPBItem.AsString;
152  
153      DPBItem :=  aDPB.Find(isc_dpb_sql_dialect);
154      if DPBItem <> nil then
# Line 217 | Line 220 | begin
220    Result := TBPB.Create;
221   end;
222  
223 < procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: string;
223 > procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: AnsiString;
224    aSQLDialect: integer);
225   begin
226    ExecImmediate(StartTransaction(TPB,taCommit),sql,aSQLDialect);
227   end;
228  
229 < procedure TFBAttachment.ExecImmediate(transaction: ITransaction; sql: string);
229 > procedure TFBAttachment.ExecImmediate(transaction: ITransaction; sql: AnsiString);
230   begin
231    ExecImmediate(transaction,sql,FSQLDialect);
232   end;
233  
234 < procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: string);
234 > procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: AnsiString);
235   begin
236    ExecImmediate(StartTransaction(TPB,taCommit),sql,FSQLDialect);
237   end;
238  
239 < function TFBAttachment.ExecuteSQL(TPB: array of byte; sql: string;
239 > function TFBAttachment.ExecuteSQL(TPB: array of byte; sql: AnsiString;
240    SQLDialect: integer; params: array of const): IResults;
241   begin
242    Result := ExecuteSQL(StartTransaction(TPB,taCommit),sql,FSQLDialect,params);
243   end;
244  
245 < function TFBAttachment.ExecuteSQL(transaction: ITransaction; sql: string;
245 > function TFBAttachment.ExecuteSQL(transaction: ITransaction; sql: AnsiString;
246    SQLDialect: integer; params: array of const): IResults;
247   begin
248    with Prepare(transaction,sql,SQLDialect) do
# Line 249 | Line 252 | begin
252    end;
253   end;
254  
255 < function TFBAttachment.ExecuteSQL(TPB: array of byte; sql: string;
255 > function TFBAttachment.ExecuteSQL(TPB: array of byte; sql: AnsiString;
256    params: array of const): IResults;
257   begin
258     Result := ExecuteSQL(StartTransaction(TPB,taCommit),sql,params);
259   end;
260  
261 < function TFBAttachment.ExecuteSQL(transaction: ITransaction; sql: string;
261 > function TFBAttachment.ExecuteSQL(transaction: ITransaction; sql: AnsiString;
262    params: array of const): IResults;
263   begin
264    with Prepare(transaction,sql,FSQLDialect) do
# Line 265 | Line 268 | begin
268    end;
269   end;
270  
271 < function TFBAttachment.OpenCursor(transaction: ITransaction; sql: string;
271 > function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString;
272    aSQLDialect: integer): IResultSet;
273   begin
274    Result := OpenCursor(transaction,sql,aSQLDialect,[]);
275   end;
276  
277 < function TFBAttachment.OpenCursor(transaction: ITransaction; sql: string;
277 > function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString;
278    aSQLDialect: integer; params: array of const): IResultSet;
279   var Statement: IStatement;
280   begin
# Line 281 | Line 284 | begin
284    Result := Statement.OpenCursor;
285   end;
286  
287 < function TFBAttachment.OpenCursor(transaction: ITransaction; sql: string
287 > function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString
288    ): IResultSet;
289   begin
290    Result := OpenCursor(transaction,sql,FSQLDialect,[]);
291   end;
292  
293 < function TFBAttachment.OpenCursor(transaction: ITransaction; sql: string;
293 > function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString;
294    params: array of const): IResultSet;
295   begin
296    Result := OpenCursor(transaction,sql,FSQLDialect,params);
297   end;
298  
299   function TFBAttachment.OpenCursorAtStart(transaction: ITransaction;
300 <  sql: string; aSQLDialect: integer): IResultSet;
300 >  sql: AnsiString; aSQLDialect: integer): IResultSet;
301   begin
302    Result := OpenCursor(transaction,sql,aSQLDialect,[]);
303    Result.FetchNext;
304   end;
305  
306   function TFBAttachment.OpenCursorAtStart(transaction: ITransaction;
307 <  sql: string; aSQLDialect: integer; params: array of const): IResultSet;
307 >  sql: AnsiString; aSQLDialect: integer; params: array of const): IResultSet;
308   begin
309    Result := OpenCursor(transaction,sql,aSQLDialect,params);
310    Result.FetchNext;
311   end;
312  
313 < function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; sql: string
313 > function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; sql: AnsiString
314    ): IResultSet;
315   begin
316    Result := OpenCursorAtStart(transaction,sql,FSQLDialect,[]);
317   end;
318  
319   function TFBAttachment.OpenCursorAtStart(transaction: ITransaction;
320 <  sql: string; params: array of const): IResultSet;
320 >  sql: AnsiString; params: array of const): IResultSet;
321   begin
322    Result := OpenCursorAtStart(transaction,sql,FSQLDialect,params);
323   end;
324  
325 < function TFBAttachment.OpenCursorAtStart(sql: string): IResultSet;
325 > function TFBAttachment.OpenCursorAtStart(sql: AnsiString): IResultSet;
326   begin
327    Result := OpenCursorAtStart(sql,[]);
328   end;
329  
330 < function TFBAttachment.OpenCursorAtStart(sql: string;
330 > function TFBAttachment.OpenCursorAtStart(sql: AnsiString;
331    params: array of const): IResultSet;
332   begin
333    Result := OpenCursorAtStart(StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit),sql,FSQLDialect,params);
334   end;
335  
336 < function TFBAttachment.Prepare(transaction: ITransaction; sql: string
336 > function TFBAttachment.Prepare(transaction: ITransaction; sql: AnsiString
337    ): IStatement;
338   begin
339    Result := Prepare(transaction,sql,FSQLDialect);
340   end;
341  
342   function TFBAttachment.PrepareWithNamedParameters(transaction: ITransaction;
343 <  sql: string; GenerateParamNames: boolean): IStatement;
343 >  sql: AnsiString; GenerateParamNames: boolean): IStatement;
344   begin
345    Result := PrepareWithNamedParameters(transaction,sql,FSQLDialect,GenerateParamNames);
346   end;
347  
348 < function TFBAttachment.GetEventHandler(Event: string): IEvents;
348 > function TFBAttachment.GetEventHandler(Event: AnsiString): IEvents;
349   var S: TStringList;
350   begin
351    S := TStringList.Create;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines