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 143 by tony, Fri Feb 23 12:11:21 2018 UTC vs.
Revision 263 by tony, Thu Dec 6 15:55:01 2018 UTC

# Line 46 | Line 46 | type
46    TFB25Attachment = class(TFBAttachment, IAttachment, IActivityMonitor)
47    private
48      FHandle: TISC_DB_HANDLE;
49 +    FFirebird25ClientAPI: TFB25ClientAPI;
50    protected
51      procedure CheckHandle; override;
52    public
53 <    constructor Create(DatabaseName: AnsiString; aDPB: IDPB;
53 >    constructor Create(api: TFB25ClientAPI; DatabaseName: AnsiString; aDPB: IDPB;
54        RaiseExceptionOnConnectError: boolean);
55 <    constructor CreateDatabase(DatabaseName: AnsiString; aDPB: IDPB; RaiseExceptionOnError: boolean); overload;
56 <    constructor CreateDatabase(sql: AnsiString; aSQLDialect: integer;
55 >    constructor CreateDatabase(api: TFB25ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; RaiseExceptionOnError: boolean); overload;
56 >    constructor CreateDatabase(api: TFB25ClientAPI; sql: AnsiString; aSQLDialect: integer;
57        RaiseExceptionOnError: boolean); overload;
58      function GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer): IDBInformation; override;
59      property Handle: TISC_DB_HANDLE read FHandle;
60 +    property Firebird25ClientAPI: TFB25ClientAPI read FFirebird25ClientAPI;
61  
62    public
63      {IAttachment}
# Line 105 | Line 107 | begin
107      IBError(ibxeDatabaseClosed,[nil]);
108   end;
109  
110 < constructor TFB25Attachment.Create(DatabaseName: AnsiString; aDPB: IDPB;
110 > constructor TFB25Attachment.Create(api: TFB25ClientAPI; DatabaseName: AnsiString; aDPB: IDPB;
111    RaiseExceptionOnConnectError: boolean);
112   begin
113 +  FFirebird25ClientAPI := api;
114    if aDPB = nil then
115    begin
116      if RaiseExceptionOnConnectError then
117         IBError(ibxeNoDPB,[nil]);
118      Exit;
119    end;
120 <  inherited Create(DatabaseName,aDPB,RaiseExceptionOnConnectError);
120 >  inherited Create(api,DatabaseName,aDPB,RaiseExceptionOnConnectError);
121    Connect;
122   end;
123  
124 < constructor TFB25Attachment.CreateDatabase(DatabaseName: AnsiString; aDPB: IDPB;
124 > constructor TFB25Attachment.CreateDatabase(api: TFB25ClientAPI; DatabaseName: AnsiString; aDPB: IDPB;
125    RaiseExceptionOnError: boolean);
126   var sql: AnsiString;
127      tr_handle: TISC_TR_HANDLE;
128   begin
129 <  inherited Create(DatabaseName,aDPB,RaiseExceptionOnError);
129 >  inherited Create(api,DatabaseName,aDPB,RaiseExceptionOnError);
130 >  FFirebird25ClientAPI := api;
131    sql := GenerateCreateDatabaseSQL(DatabaseName,aDPB);
132    tr_handle := nil;
133 <  with Firebird25ClientAPI do
133 >  with FFirebird25ClientAPI do
134    if (isc_dsql_execute_immediate(StatusVector, @FHandle, @tr_handle, 0, PAnsiChar(sql),
135                                    SQLDialect, nil) > 0) and RaiseExceptionOnError then
136      IBDataBaseError;
# Line 140 | Line 144 | begin
144      GetODSAndConnectionInfo;
145   end;
146  
147 < constructor TFB25Attachment.CreateDatabase(sql: AnsiString; aSQLDialect: integer;
147 > constructor TFB25Attachment.CreateDatabase(api: TFB25ClientAPI; sql: AnsiString; aSQLDialect: integer;
148      RaiseExceptionOnError: boolean);
149   var tr_handle: TISC_TR_HANDLE;
150   begin
151 <  inherited Create('',nil,RaiseExceptionOnError);
151 >  inherited Create(api,'',nil,RaiseExceptionOnError);
152 >  FFirebird25ClientAPI := api;
153    FSQLDialect := aSQLDialect;
154    tr_handle := nil;
155 <  with Firebird25ClientAPI do
155 >  with FFirebird25ClientAPI do
156    begin
157      if (isc_dsql_execute_immediate(StatusVector, @FHandle, @tr_handle, 0, PAnsiChar(sql),
158                                    aSQLDialect, nil) > 0) and RaiseExceptionOnError then
# Line 162 | Line 167 | end;
167   function TFB25Attachment.GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer
168    ): IDBInformation;
169   begin
170 <  Result := TDBInformation.Create;
171 <  with Firebird25ClientAPI, Result as TDBInformation do
170 >  Result := TDBInformation.Create(FFirebird25ClientAPI);
171 >  with FFirebird25ClientAPI, Result as TDBInformation do
172       if isc_database_info(StatusVector, @(FHandle), ReqBufLen, ReqBuffer,
173                                 getBufSize, Buffer) > 0 then
174            IBDataBaseError;
# Line 173 | Line 178 | procedure TFB25Attachment.Connect;
178   begin
179    FSQLDialect := 3;
180  
181 <  with Firebird25ClientAPI do
181 >  with FFirebird25ClientAPI do
182    if DPB = nil then
183    begin
184      if (isc_attach_database(StatusVector, Length(FDatabaseName),
# Line 199 | Line 204 | begin
204  
205    EndAllTransactions;
206    {Disconnect}
207 <  with Firebird25ClientAPI do
207 >  with FFirebird25ClientAPI do
208      if (isc_detach_database(StatusVector, @FHandle) > 0) and not Force then
209        IBDatabaseError;
210    FHandle := nil;
# Line 217 | Line 222 | procedure TFB25Attachment.DropDatabase;
222   begin
223    CheckHandle;
224    EndAllTransactions;
225 <  with Firebird25ClientAPI do
225 >  with FFirebird25ClientAPI do
226      if isc_drop_database(StatusVector, @FHandle) > 0 then
227        IBDatabaseError;
228    FHandle := nil;
# Line 227 | Line 232 | function TFB25Attachment.StartTransactio
232    DefaultCompletion: TTransactionCompletion): ITransaction;
233   begin
234    CheckHandle;
235 <  Result := TFB25Transaction.Create(self,TPB,DefaultCompletion);
235 >  Result := TFB25Transaction.Create(FFirebird25ClientAPI,self,TPB,DefaultCompletion);
236   end;
237  
238   function TFB25Attachment.StartTransaction(TPB: ITPB;
239    DefaultCompletion: TTransactionCompletion): ITransaction;
240   begin
241    CheckHandle;
242 <  Result := TFB25Transaction.Create(self,TPB,DefaultCompletion);
242 >  Result := TFB25Transaction.Create(FFirebird25ClientAPI,self,TPB,DefaultCompletion);
243   end;
244  
245   function TFB25Attachment.CreateBlob(transaction: ITransaction; RelationName,
# Line 281 | Line 286 | var TRHandle: TISC_TR_HANDLE;
286   begin
287    CheckHandle;
288    TRHandle := (Transaction as TFB25Transaction).Handle;
289 <  with Firebird25ClientAPI do
289 >  with FFirebird25ClientAPI do
290      if isc_dsql_execute_immediate(StatusVector, @fHandle, @TRHandle, 0,PAnsiChar(sql), aSQLDialect, nil) > 0 then
291        IBDatabaseError;
292    SignalActivity;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines