49 |
|
FFirebird25ClientAPI: TFB25ClientAPI; |
50 |
|
protected |
51 |
|
procedure CheckHandle; override; |
52 |
+ |
function GetAttachment: IAttachment; override; |
53 |
|
public |
54 |
|
constructor Create(api: TFB25ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; |
55 |
|
RaiseExceptionOnConnectError: boolean); |
66 |
|
procedure Disconnect(Force: boolean=false); override; |
67 |
|
function IsConnected: boolean; override; |
68 |
|
procedure DropDatabase; |
69 |
< |
function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; override; |
70 |
< |
function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion): ITransaction; override; |
69 |
> |
function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion; aName: AnsiString): ITransaction; override; |
70 |
> |
function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion; aName: AnsiString): ITransaction; override; |
71 |
|
procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer); override; |
72 |
|
function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; CursorName: AnsiString=''): IStatement; override; |
73 |
|
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
106 |
|
IBError(ibxeDatabaseClosed,[nil]); |
107 |
|
end; |
108 |
|
|
109 |
+ |
function TFB25Attachment.GetAttachment: IAttachment; |
110 |
+ |
begin |
111 |
+ |
Result := self; |
112 |
+ |
end; |
113 |
+ |
|
114 |
|
constructor TFB25Attachment.Create(api: TFB25ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; |
115 |
|
RaiseExceptionOnConnectError: boolean); |
116 |
|
begin |
144 |
|
Disconnect; |
145 |
|
Connect; |
146 |
|
end |
141 |
– |
else |
142 |
– |
GetODSAndConnectionInfo; |
147 |
|
end; |
148 |
|
|
149 |
|
constructor TFB25Attachment.CreateDatabase(api: TFB25ClientAPI; sql: AnsiString; aSQLDialect: integer; |
152 |
|
begin |
153 |
|
inherited Create(api,'',nil,RaiseExceptionOnError); |
154 |
|
FFirebird25ClientAPI := api; |
155 |
< |
FSQLDialect := aSQLDialect; |
155 |
> |
SetSQLDialect(aSQLDialect); |
156 |
|
tr_handle := nil; |
157 |
|
with FFirebird25ClientAPI do |
158 |
|
begin |
161 |
|
IBDataBaseError; |
162 |
|
|
163 |
|
end; |
160 |
– |
GetODSAndConnectionInfo; |
164 |
|
ExtractConnectString(sql,FDatabaseName); |
165 |
|
DPBFromCreateSQL(sql); |
166 |
|
end; |
177 |
|
|
178 |
|
procedure TFB25Attachment.Connect; |
179 |
|
begin |
180 |
< |
FSQLDialect := 3; |
180 |
> |
SetSQLDialect(3); |
181 |
|
|
182 |
|
with FFirebird25ClientAPI do |
183 |
|
if DPB = nil then |
195 |
|
IBDatabaseError; |
196 |
|
|
197 |
|
end; |
195 |
– |
GetODSAndConnectionInfo; |
198 |
|
end; |
199 |
|
|
200 |
|
procedure TFB25Attachment.Disconnect(Force: boolean); |
201 |
|
begin |
202 |
< |
if FHandle = nil then |
203 |
< |
Exit; |
204 |
< |
|
205 |
< |
EndAllTransactions; |
206 |
< |
{Disconnect} |
207 |
< |
with FFirebird25ClientAPI do |
208 |
< |
if (isc_detach_database(StatusVector, @FHandle) > 0) and not Force then |
209 |
< |
IBDatabaseError; |
210 |
< |
FHandle := nil; |
211 |
< |
FHasDefaultCharSet := false; |
210 |
< |
FCodePage := CP_NONE; |
211 |
< |
FCharSetID := 0; |
202 |
> |
if FHandle <> nil then |
203 |
> |
begin |
204 |
> |
EndAllTransactions; |
205 |
> |
{Disconnect} |
206 |
> |
with FFirebird25ClientAPI do |
207 |
> |
if (isc_detach_database(StatusVector, @FHandle) > 0) and not Force then |
208 |
> |
IBDatabaseError; |
209 |
> |
FHandle := nil; |
210 |
> |
end; |
211 |
> |
inherited Disconnect(Force); |
212 |
|
end; |
213 |
|
|
214 |
|
function TFB25Attachment.IsConnected: boolean; |
218 |
|
|
219 |
|
procedure TFB25Attachment.DropDatabase; |
220 |
|
begin |
221 |
< |
CheckHandle; |
222 |
< |
EndAllTransactions; |
223 |
< |
with FFirebird25ClientAPI do |
224 |
< |
if isc_drop_database(StatusVector, @FHandle) > 0 then |
225 |
< |
IBDatabaseError; |
226 |
< |
FHandle := nil; |
221 |
> |
if IsConnected then |
222 |
> |
begin |
223 |
> |
EndAllTransactions; |
224 |
> |
EndSession(false); |
225 |
> |
with FFirebird25ClientAPI do |
226 |
> |
if isc_drop_database(StatusVector, @FHandle) > 0 then |
227 |
> |
IBDatabaseError; |
228 |
> |
FHandle := nil; |
229 |
> |
end; |
230 |
|
end; |
231 |
|
|
232 |
|
function TFB25Attachment.StartTransaction(TPB: array of byte; |
233 |
< |
DefaultCompletion: TTransactionCompletion): ITransaction; |
233 |
> |
DefaultCompletion: TTransactionCompletion; aName: AnsiString): ITransaction; |
234 |
|
begin |
235 |
|
CheckHandle; |
236 |
< |
Result := TFB25Transaction.Create(FFirebird25ClientAPI,self,TPB,DefaultCompletion); |
236 |
> |
Result := TFB25Transaction.Create(FFirebird25ClientAPI,self,TPB,DefaultCompletion,aName); |
237 |
|
end; |
238 |
|
|
239 |
|
function TFB25Attachment.StartTransaction(TPB: ITPB; |
240 |
< |
DefaultCompletion: TTransactionCompletion): ITransaction; |
240 |
> |
DefaultCompletion: TTransactionCompletion; aName: AnsiString): ITransaction; |
241 |
|
begin |
242 |
|
CheckHandle; |
243 |
< |
Result := TFB25Transaction.Create(FFirebird25ClientAPI,self,TPB,DefaultCompletion); |
243 |
> |
Result := TFB25Transaction.Create(FFirebird25ClientAPI,self,TPB,DefaultCompletion,aName); |
244 |
|
end; |
245 |
|
|
246 |
|
function TFB25Attachment.CreateBlob(transaction: ITransaction; |