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} |
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; |
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 |
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; |
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), |
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; |
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; |
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, |
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; |