ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/client/IB.pas
Revision: 421
Committed: Sat Oct 21 14:22:28 2023 UTC (6 months, 1 week ago) by tony
Content type: text/x-pascal
File size: 69235 byte(s)
Log Message:
Release 2.6.3 Merged

File Contents

# Content
1 (*
2 * Firebird Interface (fbintf). The fbintf components provide a set of
3 * Pascal language bindings for the Firebird API. Although predominantly
4 * a new development they include source code taken from IBX and may be
5 * considered a derived product. This software thus also includes the copyright
6 * notice and license conditions from IBX.
7 *
8 * Except for those parts dervied from IBX, contents of this file are subject
9 * to the Initial Developer's Public License Version 1.0 (the "License"); you
10 * may not use this file except in compliance with the License. You may obtain a
11 * copy of the License here:
12 *
13 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
14 *
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing rights
18 * and limitations under the License.
19 *
20 * The Initial Developer of the Original Code is Tony Whyman.
21 *
22 * The Original Code is (C) 2016 Tony Whyman, MWA Software
23 * (http://www.mwasoftware.co.uk).
24 *
25 * All Rights Reserved.
26 *
27 * Contributor(s): ______________________________________.
28 *
29 *)
30 {************************************************************************}
31 { }
32 { Borland Delphi Visual Component Library }
33 { InterBase Express core components }
34 { }
35 { Copyright (c) 1998-2000 Inprise Corporation }
36 { }
37 { InterBase Express is based in part on the product }
38 { Free IB Components, written by Gregory H. Deatz for }
39 { Hoagland, Longo, Moran, Dunst & Doukas Company. }
40 { Free IB Components is used under license. }
41 { }
42 { The contents of this file are subject to the InterBase }
43 { Public License Version 1.0 (the "License"); you may not }
44 { use this file except in compliance with the License. You }
45 { may obtain a copy of the License at http://www.Inprise.com/IPL.html }
46 { Software distributed under the License is distributed on }
47 { an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either }
48 { express or implied. See the License for the specific language }
49 { governing rights and limitations under the License. }
50 { The Original Code was created by InterBase Software Corporation }
51 { and its successors. }
52 { Portions created by Inprise Corporation are Copyright (C) Inprise }
53 { Corporation. All Rights Reserved. }
54 { Contributor(s): Jeff Overcash }
55 { }
56 { IBX For Lazarus (Firebird Express) }
57 { Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk }
58 { Portions created by MWA Software are copyright McCallum Whyman }
59 { Associates Ltd 2011 - 2015 }
60 { }
61 {************************************************************************}
62 unit IB;
63 {$IFDEF MSWINDOWS}
64 {$DEFINE WINDOWS}
65 {$ENDIF}
66
67 {$IFDEF FPC}
68 {$mode delphi}
69 {$codepage UTF8}
70 {$interfaces COM}
71 {$IF defined(FPC) and (FPC_FULLVERSION < 30000) }
72 {$ERROR FPC Version 3.0.0 or later is required}
73 {$IFEND}
74 {$ENDIF}
75
76 {$IFNDEF LEGACYFIREBIRDAPIONLY}
77 {$DEFINE USEFIREBIRD3API}
78 {$ENDIF}
79 {$IFNDEF FIREBIRD3APIONLY}
80 {$DEFINE USELEGACYFIREBIRDAPI}
81 {$ENDIF}
82
83 {
84 This unit defines the interfaces used to provide the Pascal Language
85 bindings for the Firebird API. These are COM style references counted interfaces
86 and are automatically freed when they go out of scope.
87
88 The interface definition is independent of the Firebird API version and two
89 implementations are provided. One is for the legacy API (2.5 and earlier) and the
90 other is for the new object orientated API (3.0 and later). By default, both are
91 available with the 3.0 API used if it is available. Otherwise the 2.5 API is used.
92 The above two defines can be used to force only one implementation by undefining
93 the symbol for the unwanted API.
94
95 Note that the FirebirdAPI function defined below is used for initial access to
96 the language bindings.
97
98 The goals of these Pascal Langauge bindings are to provide:
99
100 1. A set of reference counted interfaces providing complete access to the Firebird API.
101
102 2. Application Independence from the Firebird API version.
103
104 3. All data access through strongly typed variables and functions with no need for
105 the end user to manipulate untyped data in buffers such as the legacy API SQLDA
106 or the Firebird 3.0 message buffer.
107
108 4. A stable platform for LCL Packages (e.g. IBX) that implement the TDataSet model
109 with independence from the Firebird API version.
110
111 5. Straightforward progammatic access to the Firebird API from Pascal programs.
112
113 6. FPC and Delphi Support.
114
115 String Types
116 ============
117
118 From FPC 3.0 onwards, ANSISTRINGs include the codepage in their definition. All
119 strings used by the interface are sensitive to the codepage in that the codepage
120 for all strings returned by an interface is consistent with the SQL Character set
121 used for the database connection. Input strings will be transliterated, where possible
122 and if necessary, to the codepage consistent with the character set used for
123 the database connection.
124 }
125
126 interface
127
128 uses
129 Classes,
130 {$IFDEF WINDOWS}Windows, {$ENDIF}
131 {$IFDEF FPC} Dynlibs, {$ENDIF}
132 SysUtils, DB, FBMessages, IBExternals, FmtBcd;
133
134 const
135 {Interface version information}
136 FBIntf_Major = 1;
137 FBIntf_Minor = 4;
138 FBIntf_Release = 0;
139 FBIntf_Version = '1.4.0';
140
141 const
142 {DPB, TPB and SPB Parameter Block Name Prefixes}
143 DPBPrefix = 'isc_dpb_';
144 TPBPrefix = 'isc_tpb_';
145
146 const
147 {Time Zone ID constraint}
148 MaxOffsetTimeZoneID = 2879; {lower values represent a time zone offset between
149 -23:59 and 23:59. Higher values are keys to the
150 Time Zone database.}
151
152 TimeZoneID_GMT = 23*minsPerHour + 59;
153 decimillisecondsPerSecond = 10000;
154 TimeZoneDisplacementDelta = 60*23 + 59; {23:59 in minutes}
155
156 {These include files are converted from the 'C' originals in the Firebird API
157 and define the various constants used by the API}
158
159 {$I 'include/consts_pub.inc'}
160 {$I 'include/dyn_consts.inc'}
161 {$I 'include/inf_pub.inc'}
162 {$I 'include/configkeys.inc'}
163 {$I 'include/blr.inc'}
164
165 {The following constants define the values return by calls to the GetSQLType
166 methods provided by several of the interfaces defined below.}
167
168 (*********************)
169 (** SQL definitions **)
170 (*********************)
171 SQL_VARYING = 448;
172 SQL_TEXT = 452;
173 SQL_DOUBLE = 480;
174 SQL_FLOAT = 482;
175 SQL_LONG = 496;
176 SQL_SHORT = 500;
177 SQL_TIMESTAMP = 510;
178 SQL_BLOB = 520;
179 SQL_D_FLOAT = 530;
180 SQL_ARRAY = 540;
181 SQL_QUAD = 550;
182 SQL_TYPE_TIME = 560;
183 SQL_TYPE_DATE = 570;
184 SQL_INT64 = 580;
185 SQL_TIMESTAMP_TZ_EX = 32748;
186 SQL_TIME_TZ_EX = 32750;
187 SQL_INT128 = 32752;
188 SQL_BOOLEAN = 32764;
189 SQL_TIMESTAMP_TZ = 32754;
190 SQL_TIME_TZ = 32756;
191 SQL_DEC_FIXED = 32758; {FB4 Beta 1 only}
192 SQL_DEC16 = 32760;
193 SQL_DEC34 = 32762;
194 SQL_NULL = 32766;
195 SQL_DATE = SQL_TIMESTAMP;
196
197 type
198 TGDS_QUAD = record
199 gds_quad_high : ISC_LONG;
200 gds_quad_low : UISC_LONG;
201 end;
202 TGDS__QUAD = TGDS_QUAD;
203 TISC_QUAD = TGDS_QUAD;
204 PGDS_QUAD = ^TGDS_QUAD;
205 PGDS__QUAD = ^TGDS__QUAD;
206 PISC_QUAD = ^TISC_QUAD;
207
208 {$IFNDEF FPC}
209 {Delphi missing definitions}
210 type
211 TLibHandle = THandle;
212
213 const
214 NilHandle = 0;
215 DirectorySeparator = '\';
216
217 {Delphi only seems to define CP_UTF8 and CP_UTF16}
218 const
219 CP_ASCII = 20127; // us-ascii
220
221 {$ENDIF}
222
223 type
224 {$IF not declared(TSystemCodePage)}
225 TSystemCodePage = word; {not defined in Delphi}
226 {$IFEND}
227
228 TIBSQLStatementTypes =
229 (SQLUnknown, SQLSelect, SQLInsert,
230 SQLUpdate, SQLDelete, SQLDDL,
231 SQLGetSegment, SQLPutSegment,
232 SQLExecProcedure, SQLStartTransaction,
233 SQLCommit, SQLRollback,
234 SQLSelectForUpdate, SQLSetGenerator,
235 SQLSavePoint);
236
237 TFBStatusCode = cardinal;
238 TByteArray = array of byte;
239 TFBTimeZoneID = ISC_USHORT;
240
241 IFirebirdAPI = interface;
242 IAttachment = interface;
243 ITransaction = interface;
244 IStatement = interface;
245
246 {The IFBNumeric interface provides a managed type for Fixed Point integers
247 used to hold Firebird Numeric(m,n) types}
248
249 IFBNumeric = interface
250 ['{8bdccfe9-d552-446b-bd82-844ca264455d}']
251 function getRawValue: Int64;
252 function getScale: integer;
253 function AdjustScaleTo(aNewScale: integer): IFBNumeric;
254 function getAsString: AnsiString;
255 function getAsDouble: double;
256 function getAsBCD: TBCD;
257 function getAsInt64: Int64; {scaled}
258 function getAsInteger: integer; {scaled - may be truncated}
259 function getAsSmallInt: SmallInt; {scaled - may be truncated}
260 function getAsCurrency: Currency;
261 end;
262
263 {The IParameterBlock interface provides the template for all parameter
264 block interfaces}
265
266 IParameterBlock<_IItem> = interface
267 function getCount: integer;
268 function Add(ParamType: byte): _IItem;
269 function getItems(index: integer): _IItem;
270 function Find(ParamType: byte): _IItem;
271 procedure PrintBuf; {can be used to print buffer in hex for debugging}
272 property Count: integer read getCount;
273 property Items[index: integer]: _IItem read getItems; default;
274 end;
275
276 IParameterBlockWithTypeNames<_IItem> = interface(IParameterBlock<_IItem>)
277 function AddByTypeName(ParamTypeName: AnsiString): _IItem;
278 function GetDPBParamTypeName(ParamType: byte): Ansistring; deprecated 'Use Get ParamTypeName';
279 function GetParamTypeName(ParamType: byte): Ansistring;
280 end;
281
282 {IParameterBlockItem is not used on its own but instead provides a base type for
283 different parameter block items }
284
285 IParameterBlockItem = interface
286 ['{53b23f7b-abda-46a5-9aa5-07bd5e723266}']
287 function getParamType: byte;
288 function getAsInteger: integer;
289 function getAsString: AnsiString;
290 function getAsByte: byte;
291 procedure setAsString(aValue: AnsiString);
292 procedure setAsByte(aValue: byte);
293 procedure SetAsInteger(aValue: integer);
294 property AsString: AnsiString read getAsString write setAsString;
295 property AsByte: byte read getAsByte write setAsByte;
296 property AsInteger: integer read getAsInteger write SetAsInteger;
297 end;
298
299 IParameterBlockItemWithTypeName = interface(IParameterBlockItem)
300 function getParamTypeName: AnsiString;
301 end;
302
303 {The IStatus interface provides access to error information, if any, returned
304 by the last API call. It can also be used to customise the error message
305 returned by a database engine exception - see EIBInterbaseError.
306
307 This interface can be accessed from IFirebirdAPI.
308 }
309
310 TIBDataBaseErrorMessage = (ShowSQLCode,
311 ShowIBMessage,
312 ShowSQLMessage);
313
314 TIBDataBaseErrorMessages = set of TIBDataBaseErrorMessage;
315
316 TStatusCode = long;
317
318 { IStatus }
319
320 IStatus = interface
321 ['{34167722-af38-4831-b08a-93162d58ede3}']
322 function InErrorState: boolean;
323 function GetIBErrorCode: TStatusCode;
324 function Getsqlcode: TStatusCode;
325 function GetMessage(CodePage: TSystemCodePage): AnsiString;
326 function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean;
327 function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages;
328 function Clone: IStatus;
329 procedure SetIBDataBaseErrorMessages(Value: TIBDataBaseErrorMessages);
330 end;
331
332 { The array metadata interface provides access to the metadata used to describe
333 an array column in a Firebird table.
334 }
335
336 TArrayBound = record
337 UpperBound: short;
338 LowerBound: short;
339 end;
340 TArrayBounds = array of TArrayBound;
341
342 IArrayMetaData = interface
343 ['{7dd0aea4-59af-4c2a-b958-565d5025c489}']
344 function GetSQLType: cardinal;
345 function GetSQLTypeName: AnsiString;
346 function GetScale: integer;
347 function GetSize: cardinal;
348 function GetCharSetWidth: integer;
349 function GetCharSetID: cardinal;
350 function GetTableName: AnsiString;
351 function GetColumnName: AnsiString;
352 function GetDimensions: integer;
353 function GetBounds: TArrayBounds;
354 end;
355
356 {The array interface provides access to and modification of the array data
357 contained in an array field of a Firebird Table. The array element is
358 selected by specifying its co-ordinates using an integer array. The
359 getter and setter methods used should be appropriate for the type of data
360 contained in the array. Automatic conversion is provided to and from strings.
361 That is GetAsString and SetAsString are safe to use for sql types other than
362 boolean.
363
364 The interface is returned by a GetAsArray getter method (see ISQLData). A new array
365 can be obtained from the IAttachment interface. The SetAsArray setter method
366 (See ISQLParam) is used to apply an updated or new array to the database using
367 an UPDATE or INSERT statement.
368
369 }
370
371 TArrayEventReason = (arChanging,arChanged);
372 IArray = interface;
373 TArrayEventHandler = procedure(Sender: IArray; Reason: TArrayEventReason) of object;
374
375 IArray = interface(IArrayMetaData)
376 ['{631c6bb1-fb49-44fb-a64a-c49859632b88}']
377 function GetArrayID: TISC_QUAD;
378 procedure Clear;
379 function IsEmpty: boolean;
380 procedure PreLoad;
381 procedure CancelChanges;
382 procedure SaveChanges;
383 function GetAsInteger(index: array of integer): integer;
384 function GetAsBoolean(index: array of integer): boolean;
385 function GetAsCurrency(index: array of integer): Currency;
386 function GetAsInt64(index: array of integer): Int64;
387 function GetAsDateTime(index: array of integer): TDateTime; overload;
388 procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
389 procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
390 procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
391 procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
392 function GetAsUTCDateTime(index: array of integer): TDateTime;
393 function GetAsDouble(index: array of integer): Double;
394 function GetAsFloat(index: array of integer): Float;
395 function GetAsLong(index: array of integer): Long;
396 function GetAsShort(index: array of integer): Short;
397 function GetAsString(index: array of integer): AnsiString;
398 function GetAsVariant(index: array of integer): Variant;
399 function GetAsBCD(index: array of integer): tBCD;
400 procedure SetAsInteger(index: array of integer; AValue: integer);
401 procedure SetAsBoolean(index: array of integer; AValue: boolean);
402 procedure SetAsCurrency(index: array of integer; Value: Currency);
403 procedure SetAsInt64(index: array of integer; Value: Int64);
404 procedure SetAsDate(index: array of integer; Value: TDateTime);
405 procedure SetAsDateTime(index: array of integer; Value: TDateTime); overload;
406 procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
407 procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZone: AnsiString); overload;
408 procedure SetAsTime(index: array of integer; Value: TDateTime); overload;
409 procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
410 procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
411 procedure SetAsUTCDateTime(index: array of integer; aUTCTime: TDateTime);
412 procedure SetAsLong(index: array of integer; Value: Long);
413 procedure SetAsDouble(index: array of integer; Value: Double);
414 procedure SetAsFloat(index: array of integer; Value: Float);
415 procedure SetAsShort(index: array of integer; Value: Short);
416 procedure SetAsString(index: array of integer; Value: AnsiString);
417 procedure SetAsVariant(index: array of integer; Value: Variant);
418 procedure SetAsBcd(index: array of integer; aValue: tBCD);
419 procedure SetBounds(dim, UpperBound, LowerBound: integer);
420 function GetAttachment: IAttachment;
421 function GetTransaction: ITransaction;
422 procedure AddEventHandler(Handler: TArrayEventHandler);
423 procedure RemoveEventHandler(Handler: TArrayEventHandler);
424 end;
425
426 { The Blob metadata interface provides access to the metadata used to describe
427 a blob column in a Firebird table.
428 }
429
430 IBlobMetaData = interface
431 ['{575f3c61-bb33-46a5-8975-bb7d1b6e37cc}']
432 function GetSubType: integer;
433 function GetCharSetID: cardinal;
434 function GetCodePage: TSystemCodePage;
435 function GetSegmentSize: cardinal;
436 function GetRelationName: AnsiString;
437 function GetColumnName: AnsiString;
438 end;
439
440 {The Blob Parameter block is used to select a Blob Filter}
441
442 IBPBItem = interface (IParameterBlockItem)
443 ['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}']
444 end;
445
446 IBPB = interface (IParameterBlock<IBPBItem>)
447 ['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}']
448 end;
449
450 { The Blob Interface provides access to a blob data item.
451
452 The interface is returned by a GetAsBlob getter method (see ISQLData). A new Blob
453 can be obtained from the IAttachment interface. The SetAsBlob setter method
454 (See ISQLParam) is used to apply an updated or new array to the database using
455 an UPDATE or INSERT statement.
456 }
457
458 TFBBlobMode = (fbmRead,fbmWrite);
459 TBlobType = (btSegmented,btStream);
460
461 IBlob = interface(IBlobMetaData)
462 ['{3090a145-7780-442b-b15b-efd4568b8611}']
463 function GetBPB: IBPB;
464 procedure Cancel;
465 procedure Close;
466 function GetBlobID: TISC_QUAD;
467 function GetBlobMode: TFBBlobMode;
468 function GetBlobSize: Int64;
469 procedure GetInfo(var NumSegments: Int64; var MaxSegmentSize,
470 TotalSize: Int64; var BlobType: TBlobType);
471 function Read(var Buffer; Count: Longint): Longint;
472 function Write(const Buffer; Count: Longint): Longint;
473 function LoadFromFile(Filename: AnsiString): IBlob;
474 function LoadFromStream(S: TStream) : IBlob;
475 function SaveToFile(Filename: AnsiString): IBlob;
476 function SaveToStream(S: TStream): IBlob;
477 function GetAsString: rawbytestring;
478 procedure SetAsString(aValue: rawbytestring);
479 function SetString(aValue: rawbytestring): IBlob;
480 function GetAttachment: IAttachment;
481 function GetTransaction: ITransaction;
482 property AsString: rawbytestring read GetAsString write SetAsString;
483 end;
484
485 { The IColumnMetaData interface provides access to the per column metadata for
486 the output of an SQL Statement.
487 }
488
489 TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP}
490 dfDateTime, {SQL DATETIME}
491 dfTime, {SQL TIME}
492 dfTimestampTZ, {SQL_TIMESTAMP_TZ}
493 dfTimeTZ); {SQLTIME_TZ
494
495 { IColumnMetaData }
496
497 IColumnMetaData = interface
498 ['{c222e6c3-53c1-469f-9e05-0a5c3ef232d8}']
499 function GetIndex: integer;
500 function GetSQLType: cardinal;
501 function GetSQLTypeName: AnsiString;
502 function getSubtype: integer;
503 function getRelationName: AnsiString;
504 function getOwnerName: AnsiString;
505 function getSQLName: AnsiString; {Name of the column}
506 function getAliasName: AnsiString; {Alias Name of column or Column Name if no alias}
507 function getName: AnsiString; {Disambiguated uppercase Field Name}
508 function getScale: integer;
509 function getCharSetID: cardinal;
510 function getCodePage: TSystemCodePage;
511 function GetCharSetWidth: integer;
512 function getIsNullable: boolean;
513 function GetSize: cardinal;
514 function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
515 function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
516 function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer;
517 function GetStatement: IStatement;
518 function GetTransaction: ITransaction;
519 function GetAttachment: IAttachment;
520 property Name: AnsiString read GetName;
521 property Size: cardinal read GetSize;
522 property SQLType: cardinal read GetSQLType;
523 property Scale: integer read getScale;
524 property SQLSubtype: integer read getSubtype;
525 property IsNullable: Boolean read GetIsNullable;
526 end;
527
528 {
529 The IMetaData interface provides access to the set of column metadata
530 for the output of an SQL Statement
531 }
532
533 { IMetaData }
534
535 IMetaData = interface
536 ['{4dafdbb6-0d36-4f1f-9c95-8b132804b965}']
537 function getCount: integer;
538 function getColumnMetaData(index: integer): IColumnMetaData;
539 function GetUniqueRelationName: AnsiString; {Non empty if all columns come from the same table}
540 function ByName(Idx: AnsiString): IColumnMetaData;
541 property ColMetaData[index: integer]: IColumnMetaData read getColumnMetaData; default;
542 property Count: integer read getCount;
543 end;
544
545 {
546 The ISQLData interface provides access to the data returned in a field in the
547 current row returned from a query or the result of an SQL Execute statement.
548
549 It subclasses IColumnMetaData and so also provides access to the metadata
550 associated with the column.
551
552 The getter and setter methods, and the corresponding properties, provide typed
553 access to the field data. The method/property used should be consistent
554 with the SQL Type. Automatic conversion is provided from strings.
555 That is GetAsString is safe to use for sql types other than boolean.
556 }
557
558
559 ISQLData = interface(IColumnMetaData)
560 ['{3f493e31-7e3f-4606-a07c-b210b9e3619d}']
561 function GetStrDataLength: short;
562 function GetAsBoolean: boolean;
563 function GetAsCurrency: Currency;
564 function GetAsInt64: Int64;
565 function GetAsDateTime: TDateTime; overload;
566 procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
567 procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
568 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
569 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
570 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
571 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
572 function GetAsUTCDateTime: TDateTime;
573 function GetAsDouble: Double;
574 function GetAsFloat: Float;
575 function GetAsLong: Long;
576 function GetAsPointer: Pointer;
577 function GetAsQuad: TISC_QUAD;
578 function GetAsShort: short;
579 function GetAsString: AnsiString;
580 function GetIsNull: Boolean;
581 function GetAsVariant: Variant;
582 function GetAsBlob: IBlob; overload;
583 function GetAsBlob(BPB: IBPB): IBlob; overload;
584 function GetAsArray: IArray;
585 function GetAsBCD: tBCD;
586 function GetAsNumeric: IFBNumeric;
587 property AsDate: TDateTime read GetAsDateTime;
588 property AsBoolean:boolean read GetAsBoolean;
589 property AsTime: TDateTime read GetAsDateTime;
590 property AsDateTime: TDateTime read GetAsDateTime ;
591 property AsDouble: Double read GetAsDouble;
592 property AsFloat: Float read GetAsFloat;
593 property AsCurrency: Currency read GetAsCurrency;
594 property AsInt64: Int64 read GetAsInt64 ;
595 property AsInteger: Integer read GetAsLong;
596 property AsLong: Long read GetAsLong;
597 property AsPointer: Pointer read GetAsPointer;
598 property AsQuad: TISC_QUAD read GetAsQuad;
599 property AsShort: short read GetAsShort;
600 property AsString: AnsiString read GetAsString;
601 property AsVariant: Variant read GetAsVariant ;
602 property AsBlob: IBlob read GetAsBlob;
603 property AsArray: IArray read GetAsArray;
604 property AsBCD: tBCD read GetAsBCD;
605 property AsNumeric: IFBNumeric read GetAsNumeric;
606 property IsNull: Boolean read GetIsNull;
607 property Value: Variant read GetAsVariant;
608 end;
609
610 { An IResults interface is returned as the result of an SQL Execute statement
611 and provides access to the fields returned, if any. It is a collection of
612 ISQLData interfaces which are, in turn, used to access the data returned by
613 each field of the result set.
614 }
615
616 IResults = interface
617 ['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}']
618 function getCount: integer;
619 function GetStatement: IStatement;
620 function GetTransaction: ITransaction;
621 function GetAttachment: IAttachment;
622 function FieldExists(Idx: AnsiString): boolean;
623 function ByName(Idx: AnsiString): ISQLData;
624 function getSQLData(index: integer): ISQLData;
625 procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
626 procedure SetRetainInterfaces(aValue: boolean);
627 property Data[index: integer]: ISQLData read getSQLData; default;
628 property Count: integer read getCount;
629 end;
630
631 { An IResultSet interface is returned as the result of an SQL Open Cursor statement
632 (e.g. Select Statement) and provides access to the fields returned, if any
633 for the current row. It is a collection of ISQLData interfaces which are,
634 in turn, used to access the data returned by each field of the current row.
635 }
636 IResultSet = interface(IResults)
637 ['{0ae4979b-7857-4e8c-8918-ec6f155b51a0}']
638 function FetchNext: boolean; {fetch next record}
639 function FetchPrior: boolean; {fetch previous record}
640 function FetchFirst:boolean; {fetch first record}
641 function FetchLast: boolean; {fetch last record}
642 function FetchAbsolute(position: Integer): boolean; {fetch record by its absolute position in result set}
643 function FetchRelative(offset: Integer): boolean; {fetch record by position relative to current}
644 function GetCursorName: AnsiString;
645 function IsBof: boolean;
646 function IsEof: boolean;
647 procedure Close;
648 end;
649
650 {The ISQLParam interface is used to provide access to each parameter in a
651 parametised SQL Statement. The interface comprises the Setter Methods and properties used to
652 set the value of each parameter.
653
654 Automatic conversion is provided to and from strings. That is GetAsString and
655 SetAsString are safe to use for sql types other than boolean - provided automatic
656 conversion is possible.
657
658 ISQLParam is subclassed from the IParamMetaData interface. This interface provides
659 access to the parameter metadata. This metadata is mutable and can change after
660 a parameter is set to a given value. This is acceptable as long as the parameter
661 metadata is type compatible with the underlying column metadata and hence the
662 parameter value can be converted by Firebird into a value acceptable by the
663 underlying column. The column metadata, which is unmutable, can be obtained
664 by the ISQLParam.getColMetadata interface. When a statement is prepared, the
665 parameter metadata is always initialised to the column metadata.
666 }
667
668 IParamMetaData = interface
669 ['{4e148c4e-2d48-4991-a263-f66eca05c6aa}']
670 function GetSQLType: cardinal;
671 function GetSQLTypeName: AnsiString;
672 function getSubtype: integer;
673 function getScale: integer;
674 function getCharSetID: cardinal;
675 function getCodePage: TSystemCodePage;
676 function getIsNullable: boolean;
677 function GetSize: cardinal;
678 property SQLType: cardinal read GetSQLType;
679 end;
680
681 ISQLParam = interface(IParamMetaData)
682 ['{b22b4578-6d41-4807-a9a9-d2ec8d1d5a14}']
683 function getColMetadata: IParamMetaData;
684 function GetStatement: IStatement;
685 function GetTransaction: ITransaction;
686 function GetAttachment: IAttachment;
687 function GetIndex: integer;
688 function getName: AnsiString;
689 function GetAsBoolean: boolean;
690 function GetAsCurrency: Currency;
691 function GetAsInt64: Int64;
692 function GetAsDateTime: TDateTime; overload;
693 procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
694 procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
695 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
696 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
697 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
698 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
699 function GetAsUTCDateTime: TDateTime;
700 function GetAsDouble: Double;
701 function GetAsFloat: Float;
702 function GetAsLong: Long;
703 function GetAsPointer: Pointer;
704 function GetAsQuad: TISC_QUAD;
705 function GetAsShort: short;
706 function GetAsString: AnsiString;
707 function GetIsNull: boolean;
708 function GetAsVariant: Variant;
709 function GetAsBlob: IBlob;
710 function GetAsArray: IArray;
711 function GetAsBCD: tBCD;
712 function GetAsNumeric: IFBNumeric;
713 procedure Clear;
714 function GetModified: boolean;
715 procedure SetAsBoolean(AValue: boolean);
716 procedure SetAsCurrency(aValue: Currency);
717 procedure SetAsInt64(aValue: Int64);
718 procedure SetAsDate(aValue: TDateTime);
719 procedure SetAsLong(aValue: Long);
720 procedure SetAsTime(aValue: TDateTime); overload;
721 procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
722 procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
723 procedure SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
724 procedure SetAsTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
725 procedure SetAsDateTime(aValue: TDateTime); overload;
726 procedure SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
727 procedure SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
728 procedure SetAsUTCDateTime(aUTCTime: TDateTime);
729 procedure SetAsDouble(aValue: Double);
730 procedure SetAsFloat(aValue: Float);
731 procedure SetAsPointer(aValue: Pointer);
732 procedure SetAsShort(aValue: Short);
733 procedure SetAsString(aValue: AnsiString);
734 procedure SetAsVariant(aValue: Variant);
735 procedure SetIsNull(aValue: Boolean);
736 procedure SetAsBlob(aValue: IBlob);
737 procedure SetAsArray(anArray: IArray);
738 procedure SetAsQuad(aValue: TISC_QUAD);
739 procedure SetCharSetID(aValue: cardinal);
740 procedure SetAsBcd(aValue: tBCD);
741 procedure SetAsNumeric(Value: IFBNumeric);
742 property AsDate: TDateTime read GetAsDateTime write SetAsDate;
743 property AsBoolean:boolean read GetAsBoolean write SetAsBoolean;
744 property AsTime: TDateTime read GetAsDateTime write SetAsTime;
745 property AsDateTime: TDateTime read GetAsDateTime write SetAsDateTime;
746 property AsDouble: Double read GetAsDouble write SetAsDouble;
747 property AsFloat: Float read GetAsFloat write SetAsFloat;
748 property AsCurrency: Currency read GetAsCurrency write SetAsCurrency;
749 property AsInt64: Int64 read GetAsInt64 write SetAsInt64;
750 property AsInteger: Integer read GetAsLong write SetAsLong;
751 property AsLong: Long read GetAsLong write SetAsLong;
752 property AsPointer: Pointer read GetAsPointer write SetAsPointer;
753 property AsShort: Short read GetAsShort write SetAsShort;
754 property AsString: AnsiString read GetAsString write SetAsString;
755 property AsVariant: Variant read GetAsVariant write SetAsVariant;
756 property AsBlob: IBlob read GetAsBlob write SetAsBlob;
757 property AsArray: IArray read GetAsArray write SetAsArray;
758 property AsBCD: tBCD read GetAsBCD write SetAsBCD;
759 property AsNumeric: IFBNumeric read GetAsNumeric write SetAsNumeric;
760 property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad;
761 property Value: Variant read GetAsVariant write SetAsVariant;
762 property IsNull: Boolean read GetIsNull write SetIsNull;
763 property IsNullable: Boolean read GetIsNullable;
764 property Modified: Boolean read getModified;
765 property Name: AnsiString read GetName;
766 end;
767
768 {
769 The ISQLParams interface provides access to the collection of parameters used
770 for the input to an SQL Statement
771 }
772
773 { ISQLParams }
774
775 ISQLParams = interface
776 ['{c6d95ac7-b2b7-461b-b890-afef0acbb077}']
777 function getCount: integer;
778 function getSQLParam(index: integer): ISQLParam;
779 function ParamExists(Idx: AnsiString): boolean;
780 function ByName(Idx: AnsiString): ISQLParam ;
781 function GetModified: Boolean;
782 function GetHasCaseSensitiveParams: Boolean;
783 function GetStatement: IStatement;
784 function GetTransaction: ITransaction;
785 function GetAttachment: IAttachment;
786 procedure Clear;
787 property Modified: Boolean read GetModified;
788 property Params[index: integer]: ISQLParam read getSQLParam; default;
789 property Count: integer read getCount;
790 end;
791
792
793 TPerfStats = (psCurrentMemory, psMaxMemory,
794 psRealTime, psUserTime, psBuffers,
795 psReads, psWrites, psFetches,psDeltaMemory);
796
797 TPerfCounters = array[TPerfStats] of Int64;
798
799 {Batch Query Execution Support}
800
801 TBatchCompletionState = (bcExecuteFailed, bcSuccessNoInfo, bcNoMoreErrors);
802
803 IBatchCompletion = interface
804 ['{9bc3d49d-16d9-4606-94e5-ee987103ad92}']
805 function getTotalProcessed: cardinal;
806 function getState(updateNo: cardinal): TBatchCompletionState;
807 function getStatusMessage(updateNo: cardinal): AnsiString;
808 function getUpdated: integer;
809 function getErrorStatus(var RowNo: integer; var status: IStatus): boolean;
810 end;
811
812 {The IStatement interface provides access to an SQL Statement once it has been
813 initially prepared. The interface is returned from the IAttachment interface.
814 }
815
816 TStatementFlag = (stHasCursor,stRepeatExecute,stScrollable);
817 TStatementFlags = set of TStatementFlag;
818
819 IStatement = interface
820 ['{a260576d-a07d-4a66-b02d-1b72543fd7cf}']
821 function GetMetaData: IMetaData; {Output Metadata}
822 function GetSQLParams: ISQLParams;{Statement Parameters}
823 function GetPlan: AnsiString;
824 function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
825 function GetSQLStatementType: TIBSQLStatementTypes;
826 function GetSQLStatementTypeName: AnsiString;
827 function GetSQLText: AnsiString;
828 function GetProcessedSQLText: AnsiString;
829 function GetSQLDialect: integer;
830 function GetFlags: TStatementFlags;
831 function IsPrepared: boolean;
832 function HasBatchMode: boolean;
833 function IsInBatchMode: boolean;
834 procedure Prepare(aTransaction: ITransaction=nil); overload;
835 procedure Prepare(CursorName: AnsiString; aTransaction: ITransaction=nil); overload;
836 function Execute(aTransaction: ITransaction=nil): IResults;
837 function OpenCursor(aTransaction: ITransaction=nil): IResultSet; overload;
838 function OpenCursor(Scrollable: boolean; aTransaction: ITransaction=nil): IResultSet; overload;
839 function GetAttachment: IAttachment;
840 function GetTransaction: ITransaction;
841 procedure SetRetainInterfaces(aValue: boolean);
842 procedure EnableStatistics(aValue: boolean);
843 function GetPerfStatistics(var stats: TPerfCounters): boolean;
844 {IBatch interface support}
845 procedure AddToBatch;
846 function ExecuteBatch(aTransaction: ITransaction=nil): IBatchCompletion;
847 procedure CancelBatch;
848 function GetBatchCompletion: IBatchCompletion;
849 function GetBatchRowLimit: integer;
850 procedure SetBatchRowLimit(aLimit: integer);
851 {Stale Reference Check}
852 procedure SetStaleReferenceChecks(Enable:boolean); {default true}
853 function GetStaleReferenceChecks: boolean;
854
855 property MetaData: IMetaData read GetMetaData;
856 property SQLParams: ISQLParams read GetSQLParams;
857 property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType;
858 end;
859
860 ITrInfoItem = interface
861 ['{41455e1a-f84e-4e26-aff0-1a78e8b69cfe}']
862 function getItemType: byte;
863 function getSize: integer;
864 function getAsString: AnsiString;
865 function getAsInteger: int64;
866 procedure DecodeTraIsolation(var IsolationType, RecVersion: byte);
867 end;
868
869 { ITrInformation }
870
871 ITrInformation = interface
872 ['{e6ea4a52-c1a1-44ba-9609-c8bcc7cba7b2}']
873 function GetCount: integer;
874 function GetItem(index: integer): ITrInfoItem;
875 function Find(ItemType: byte): ITrInfoItem;
876 procedure PrintBuf; {can be used to print buffer in hex for debugging}
877 property Count: integer read GetCount;
878 property Items[index: integer]: ITrInfoItem read getItem; default;
879 end;
880
881 {Transaction Parameter Block: (TPB)
882
883 The TPB provides the parameters used when starting a transaction. It is allocated
884 empty by the FirebirdAPI and the parameters are then added to it. Each individual
885 parameter may be accessed by the ITPBItem interface which can be used to set the
886 value, if any, of the parameter.
887
888 The TPB parameters, and the associated symbolic codes and parameter values may be
889 found in the Interbase 6.0 API Guide.
890 }
891
892 ITPBItem = interface(IParameterBlockItemWithTypeName)
893 ['{544c1f2b-7c12-4a87-a4a5-face7ea72671}']
894 end;
895
896 ITPB = interface(IParameterBlockWithTypeNames<ITPBItem>)
897 ['{7369b0ff-defe-437b-81fe-19b211d42d25}']
898 function AsText: AnsiString;
899 end;
900
901 {The ITransactionAction interface provides access to a Transaction once it
902 has been initially started. After a Commit or Rollback, a transaction
903 may be restarted, optinally with a new TPB.
904
905 A multi-database transaction is started from the FirebirdAPI. A single database
906 transaction is started from the IAttachment interface.
907 }
908
909 TTransactionAction = (TARollback, TACommit, TACommitRetaining, TARollbackRetaining);
910 TTransactionCompletion = TARollback.. TACommit;
911 TTrCompletionState = (trCommitted, trRolledback, trCommitFailed, trRollbackFailed);
912
913
914 ITransaction = interface
915 ['{30928d0e-a9d7-4c61-b7cf-14f4f38abe2a}']
916 function getTPB: ITPB;
917 procedure Start(DefaultCompletion: TTransactionCompletion=taCommit);
918 function GetInTransaction: boolean;
919 function GetIsReadOnly: boolean;
920 function GetTransactionID: integer;
921 function GetJournalingActive(attachment: IAttachment): boolean;
922 function GetDefaultCompletion: TTransactionCompletion;
923 procedure PrepareForCommit; {Two phase commit - stage 1}
924 function Commit(Force: boolean=false): TTrCompletionState;
925 procedure CommitRetaining;
926 function HasActivity: boolean;
927 function Rollback(Force: boolean=false): TTrCompletionState;
928 procedure RollbackRetaining;
929 function GetAttachmentCount: integer;
930 function GetAttachment(index: integer): IAttachment;
931 function GetTrInformation(Requests: array of byte): ITrInformation; overload;
932 function GetTrInformation(Request: byte): ITrInformation; overload;
933 function GetTransactionName: AnsiString;
934 procedure SetTransactionName(aValue: AnsiString);
935 property InTransaction: boolean read GetInTransaction;
936 property TransactionName: AnsiString read GetTransactionName write SetTransactionName;
937 end;
938
939 { The IEvents Interface is used to handle events from a single database. The
940 interface is allocated from the IAttachment Interface.
941
942 Note that the EventHandler called when an event occurs following AsynWaitForEvent
943 is called in a different thread to the calling program and TThread.Synchronize
944 may be needed to pass the event back to the main thread.
945
946 Neither AsyncWaitForEvent nor WaitForEvent is intended to be thread safe
947 in a multi-threaded environment and should always be called from the main
948 thread.
949 }
950
951 TEventInfo = record
952 EventName: AnsiString;
953 Count: integer;
954 end;
955
956 TEventCounts = array of TEventInfo;
957 IEvents = interface;
958 TEventHandler = procedure(Sender: IEvents) of object;
959
960 { IEvents }
961
962 IEvents = interface
963 ['{6a0be233-ed08-4524-889c-2e45d0c20e5f}']
964 procedure GetEvents(EventNames: TStrings);
965 procedure SetEvents(EventNames: TStrings); overload;
966 procedure SetEvents(EventName: string); overload;
967 procedure Cancel;
968 function ExtractEventCounts: TEventCounts;
969 procedure WaitForEvent;
970 procedure AsyncWaitForEvent(EventHandler: TEventHandler);
971 function GetAttachment: IAttachment;
972 end;
973
974 TTZTextOptions = (tzOffset, {Time Zone Rendered as an offset to GMT}
975 tzGMT, {No Time Zone. Time part is always rendered in GMT}
976 tzOriginalID); {Time Zone shown as originally entered}
977
978 {The ITimeZoneServices interface provides access to the time zone database
979 used for the attachment. It may be used in support of TIMESTAMP WITH TIME ZONE
980 and TIME WITH TIME ZONE data types.}
981
982 ITimeZoneServices = interface
983 ['{163821f5-ebef-42b9-ac60-8ac4b5c09954}']
984 {utility functions}
985 function TimeZoneID2TimeZoneName(aTimeZoneID: TFBTimeZoneID): AnsiString;
986 function TimeZoneName2TimeZoneID(aTimeZone: AnsiString): TFBTimeZoneID;
987 function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
988 function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
989 function GMTToLocalTime(aGMTTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
990 function GMTToLocalTime(aGMTTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
991 function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZone: AnsiString): integer; overload;
992 function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): integer; overload;
993
994 {Time Zone DB Information}
995 function UsingRemoteTZDB: boolean;
996 procedure SetUseLocalTZDB(useLocalTZDB: boolean);
997 function GetLocalTimeZoneName: AnsiString;
998 function GetLocalTimeZoneID: TFBTimeZoneID;
999 procedure GetTimeZoneInfo(aTimeZone: AnsiString; OnDate: TDateTime;
1000 var ZoneOffset, DSTOffset, EffectiveOffset: integer);
1001 {Configurable Options}
1002 function GetTimeTZDate: TDateTime;
1003 procedure SetTimeTZDate(aDate: TDateTime);
1004 function GetTZTextOption: TTZTextOptions;
1005 procedure SetTZTextOption(aOptionValue: TTZTextOptions);
1006 end;
1007
1008 {The IDBInformation Interface.
1009
1010 An IDBInformation interface is returned by the IAttachment GetDBInformation
1011 method. The interface provides access to the information requested and
1012 returned by the method.
1013
1014 IDBInformation itself gives access to a collection of IDBInfoItems. Each one
1015 provides information requested, as indicated by the ItemType and the actual
1016 value of the information. In some cases, the returned item is itself a
1017 colletion of IDBInfoItems.
1018
1019 The IDBInformation items, and the associated symbolic codes and parameter values may be
1020 found in the Interbase 6.0 API Guide.
1021 }
1022
1023 TDBOperationCount = record
1024 TableID: UShort;
1025 Count: cardinal;
1026 end;
1027
1028 TDBOperationCounts = array of TDBOperationCount;
1029
1030 IDBInfoItem = interface
1031 ['{eeb97b51-ec0f-473f-9f75-c1721f055fcb}']
1032 function getItemType: byte;
1033 function getSize: integer;
1034 procedure getRawBytes(var Buffer);
1035 function getAsString: AnsiString;
1036 function getAsInteger: int64;
1037 procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString);
1038 function getAsBytes: TByteArray;
1039 function getAsDateTime: TDateTime;
1040 procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
1041 function getOperationCounts: TDBOperationCounts;
1042 procedure DecodeUserNames(UserNames: TStrings);
1043
1044 {user names only}
1045 function GetCount: integer;
1046 function GetItem(index: integer): IDBInfoItem;
1047 function Find(ItemType: byte): IDBInfoItem;
1048 property AsInteger: int64 read getAsInteger;
1049 property AsString: AnsiString read GetAsString;
1050 property Count: integer read GetCount;
1051 property Items[index: integer]: IDBInfoItem read getItem; default;
1052 end;
1053
1054 { IDBInformation }
1055
1056 IDBInformation = interface
1057 ['{7ac6777f-f0a9-498a-9f5c-4a57a554df81}']
1058 function GetCount: integer;
1059 function GetItem(index: integer): IDBInfoItem;
1060 function Find(ItemType: byte): IDBInfoItem;
1061 procedure PrintBuf; {can be used to print buffer in hex for debugging}
1062 property Count: integer read GetCount;
1063 property Items[index: integer]: IDBInfoItem read getItem; default;
1064 end;
1065
1066 {The Database Information Request Block is used to pass requests for
1067 database information where at least one item requested has a parameter.
1068 At present, this is only fb_info_page_contents which has a single
1069 integer parameter.}
1070
1071 IDIRBItem = interface(IParameterBlockItem)
1072 ['{d34a7511-8435-4a24-81a7-5103d218d234}']
1073 end;
1074
1075 IDIRB = interface(IParameterBlock<IDIRBItem>)
1076 ['{1010e5ac-0a8f-403b-a302-91625e9d9579}']
1077 end;
1078
1079
1080 {The Database Parameter Block (DPB).
1081
1082 The DPB provides the parameters used when connecting to a database. It is allocated
1083 empty by the FirebirdAPI and the parameters are then added to it. Each individual
1084 parameter may be accessed by the IDPBItem interface which can be used to set the
1085 value, if any, of the parameter.
1086
1087 The DPB parameters, and the associated symbolic codes and parameter values may be
1088 found in the Interbase 6.0 API Guide.
1089 }
1090
1091 IDPBItem = interface(IParameterBlockItemWithTypeName)
1092 ['{123d4ad0-087a-4cd1-a344-1b3d03b30673}']
1093 end;
1094
1095 IDPB = interface(IParameterBlockWithTypeNames<IDPBItem>)
1096 ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
1097 end;
1098
1099 {Journaling options. Default is [joReadWriteTransactions,joModifyQueries] }
1100
1101 TJournalOption = (joReadOnlyTransactions, joReadWriteTransactions,
1102 joModifyQueries, joReadOnlyQueries,joNoServerTable);
1103
1104 TJournalOptions = set of TJournalOption;
1105
1106 {The IAttachment interface provides access to a Database Connection. It may be
1107 used to:
1108
1109 a. Disconnect and reconnect to the database.
1110
1111 b. Start a Transaction on the database
1112
1113 c. Execute directly SQL DDL Statements and others that return no information.
1114
1115 d. OpenCursors (i.e. execute SQL Select statements and return the results)
1116
1117 e. Prepare SQL Statements, returning an IStatement interface for further processing.
1118
1119 f. Provide access to an SQL Event Handler.
1120
1121 g. Access Database Information.
1122
1123 h. Support the handling of Array and Blob data.
1124
1125 Note that SQL statements can be prepared with named parameters (PSQL style).
1126 This then allows the parameters to be accessed by name. The same name can
1127 be used for more than one parameter, allowing a single operation to be used
1128 to set all parameters with the same name.
1129 }
1130
1131 { IAttachment }
1132
1133 IAttachment = interface
1134 ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
1135 function getFirebirdAPI: IFirebirdAPI;
1136 function getDPB: IDPB;
1137 function AllocateBPB: IBPB;
1138 function AllocateDIRB: IDIRB;
1139 procedure Connect;
1140 procedure Disconnect(Force: boolean=false);
1141 function IsConnected: boolean;
1142 procedure DropDatabase;
1143 function StartTransaction(TPB: array of byte;
1144 DefaultCompletion: TTransactionCompletion=taCommit;
1145 aName: AnsiString=''): ITransaction; overload;
1146 function StartTransaction(TPB: ITPB;
1147 DefaultCompletion: TTransactionCompletion=taCommit;
1148 aName: AnsiString=''): ITransaction; overload;
1149 procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; SQLDialect: integer); overload;
1150 procedure ExecImmediate(TPB: array of byte; sql: AnsiString; SQLDialect: integer); overload;
1151 procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload;
1152 procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload;
1153 function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
1154 function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
1155 function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload;
1156 function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload;
1157 function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1158 Scrollable: boolean=false): IResultSet; overload;
1159 function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1160 params: array of const): IResultSet; overload;
1161 function OpenCursor(transaction: ITransaction; sql: AnsiString; Scrollable: boolean=false): IResultSet; overload;
1162 function OpenCursor(transaction: ITransaction; sql: AnsiString; Scrollable: boolean;
1163 params: array of const): IResultSet; overload;
1164 function OpenCursor(transaction: ITransaction; sql: AnsiString;
1165 params: array of const): IResultSet; overload;
1166 function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; Scrollable: boolean;
1167 params: array of const): IResultSet; overload;
1168 function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1169 Scrollable: boolean=false): IResultSet; overload;
1170 function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1171 params: array of const): IResultSet; overload;
1172 function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; Scrollable: boolean;
1173 params: array of const): IResultSet; overload;
1174 function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; Scrollable: boolean=false): IResultSet; overload;
1175 function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString;
1176 params: array of const): IResultSet; overload;
1177 function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; Scrollable: boolean;
1178 params: array of const): IResultSet; overload;
1179 function OpenCursorAtStart(sql: AnsiString; Scrollable: boolean=false): IResultSet; overload;
1180 function OpenCursorAtStart(sql: AnsiString; Scrollable: boolean;
1181 params: array of const): IResultSet; overload;
1182 function OpenCursorAtStart(sql: AnsiString;
1183 params: array of const): IResultSet; overload;
1184 function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; CursorName: AnsiString=''): IStatement; overload;
1185 function Prepare(transaction: ITransaction; sql: AnsiString; CursorName: AnsiString=''): IStatement; overload;
1186 function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1187 aSQLDialect: integer; GenerateParamNames: boolean=false;
1188 CaseSensitiveParams: boolean = false; CursorName: AnsiString=''): IStatement; overload;
1189 function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1190 GenerateParamNames: boolean=false;
1191 CaseSensitiveParams: boolean = false; CursorName: AnsiString=''): IStatement; overload;
1192
1193 {Events}
1194 function GetEventHandler(Events: TStrings): IEvents; overload;
1195 function GetEventHandler(Event: AnsiString): IEvents; overload;
1196
1197 {Blob - may use to open existing Blobs. However, ISQLData.AsBlob is preferred}
1198
1199 function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
1200 function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
1201 function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
1202 function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
1203 function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
1204 function GetInlineBlobLimit: integer;
1205 procedure SetInlineBlobLimit(limit: integer);
1206
1207 {Array - may use to open existing arrays. However, ISQLData.AsArray is preferred}
1208
1209 function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload;
1210 function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload;
1211 function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload;
1212 function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
1213 function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
1214 Scale: integer; size: cardinal; charSetID: cardinal; dimensions: cardinal;
1215 bounds: TArrayBounds): IArrayMetaData;
1216
1217 {Database Information}
1218 function GetSQLDialect: integer;
1219 function GetAttachmentID: integer;
1220 function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData;
1221 function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
1222 function GetDBInformation(Requests: array of byte): IDBInformation; overload;
1223 function GetDBInformation(Request: byte): IDBInformation; overload;
1224 function GetDBInformation(Requests: IDIRB): IDBInformation; overload;
1225 function GetConnectString: AnsiString;
1226 function GetRemoteProtocol: AnsiString;
1227 function GetAuthenticationMethod: AnsiString;
1228 function GetSecurityDatabase: AnsiString;
1229 function GetODSMajorVersion: integer;
1230 function GetODSMinorVersion: integer;
1231 procedure getFBVersion(version: TStrings);
1232 function HasActivity: boolean;
1233 function HasDecFloatSupport: boolean;
1234 function HasBatchMode: boolean;
1235 function HasScollableCursors: boolean;
1236 function HasTable(aTableName: AnsiString): boolean; {case sensitive}
1237 function HasFunction(aFunctionName: AnsiString): boolean; {case sensitive}
1238 function HasProcedure(aProcName: AnsiString): boolean; {case sensitive}
1239
1240 {Character Sets}
1241 function GetCharSetID: integer; {connection character set}
1242 function GetCodePage: TSystemCodePage;
1243 function HasDefaultCharSet: boolean;
1244 function GetDefaultCharSetID: integer;
1245 function GetCharsetName(CharSetID: integer): AnsiString;
1246 function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
1247 function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
1248 function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean;
1249 function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
1250 procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
1251 AllowReverseLookup:boolean; out CharSetID: integer);
1252
1253 {Time Zone Database}
1254 function GetTimeZoneServices: ITimeZoneServices;
1255 function HasTimeZoneSupport: boolean;
1256
1257 {Client side Journaling}
1258 function JournalingActive: boolean;
1259 function GetJournalOptions: TJournalOptions;
1260 function StartJournaling(aJournalLogFile: AnsiString): integer; overload;
1261 function StartJournaling(aJournalLogFile: AnsiString; Options: TJournalOptions): integer; overload;
1262 function StartJournaling(S: TStream; Options: TJournalOptions): integer; overload;
1263 procedure StopJournaling(RetainJournal: boolean);
1264 end;
1265
1266 TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
1267 TProtocol = TCP..xnet;
1268
1269 {Service Parameter Block (SPB).
1270
1271 The SPB provides the parameters used when connecting to a Service Manager. It is
1272 allocated empty by the FirebirdAPI and the parameters are then added to it. Each
1273 individual parameter may be accessed by the ISPBItem interface which can be used
1274 to set the value, if any, of the parameter.
1275
1276 The SPB parameters, and the associated symbolic codes and parameter values may be
1277 found in the Interbase 6.0 API Guide.
1278
1279 }
1280
1281 ISPBItem = interface(IParameterBlockItemWithTypeName)
1282 ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
1283 end;
1284
1285 ISPB = interface(IParameterBlockWithTypeNames<ISPBItem>)
1286 ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
1287 end;
1288
1289 {Service Query Parameter Block (SQPB).
1290
1291 This is a specialised parameter block used to send data to a service manager
1292 in a Query Request.
1293 }
1294
1295 ISQPBItem = interface(IParameterBlockItem)
1296 ['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}']
1297 function CopyFrom(source: TStream; count: integer): integer;
1298 end;
1299
1300 ISQPB = interface(IParameterBlock<ISQPBItem>)
1301 ['{8553e66b-ee62-498b-8431-dff030211447}']
1302 end;
1303
1304 {Service Request Block (SRB).
1305
1306 The SRB specifies what is requested from the Service Manager when starting a
1307 service or querying a service. It is allocated empty by the ServiceManager API and
1308 the parameters are then added to it. Each individual parameter may be accessed
1309 by the ISRBItem interface which can be used to set the value, if any, of the parameter.
1310
1311 The SRB parameters, and the associated symbolic codes and parameter values may be
1312 found in the Interbase 6.0 API Guide.
1313
1314 }
1315
1316 ISRBItem = interface(IParameterBlockItem)
1317 ['{47ec790e-f265-4b30-9dcd-261e51677245}']
1318 end;
1319
1320 ISRB = interface(IParameterBlock<ISRBItem>)
1321 ['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}']
1322 end;
1323
1324 {The Service Query Results Interface.
1325
1326 An IServiceQueryResults interface is returned by the IServiceManager Query
1327 method. The interface provides access to the information requested and
1328 returned by the method.
1329
1330 IServiceQueryResults itself gives access to a collection of IServiceQueryResultItem.
1331 Each one provides information requested, as indicated by the ItemType and the actual
1332 value of the information. In some cases, the returned item is itself a
1333 collection of IServiceQueryResultSubItem.
1334
1335 The IServiceQueryResultItem items, and the associated symbolic codes and parameter values may be
1336 found in the Interbase 6.0 API Guide.
1337 }
1338
1339 IServiceQueryResultSubItem = interface
1340 ['{8a4c381e-9923-4cc9-a96b-553729248640}']
1341 function getItemType: byte;
1342 function getSize: integer;
1343 procedure getRawBytes(var Buffer);
1344 function getAsString: AnsiString;
1345 function getAsInteger: int64;
1346 function getAsByte: byte;
1347 function CopyTo(stream: TStream; count: integer): integer;
1348 property AsString: AnsiString read getAsString;
1349 property AsInteger: int64 read getAsInteger;
1350 property AsByte: byte read getAsByte;
1351 end;
1352
1353 IServiceQueryResultItem = interface(IServiceQueryResultSubItem)
1354 ['{b2806886-206c-4024-8df9-5fe0a7630a5e}']
1355 function getCount: integer;
1356 function getItem(index: integer): IServiceQueryResultSubItem;
1357 function find(ItemType: byte): IServiceQueryResultSubItem;
1358 property Items[index: integer]: IServiceQueryResultSubItem read getItem; default;
1359 property Count: integer read getCount;
1360 end;
1361
1362 IServiceQueryResults = interface
1363 ['{8fbbef7d-fe03-4409-828a-a787d34ef531}']
1364 function getCount: integer;
1365 function getItem(index: integer): IServiceQueryResultItem;
1366 function find(ItemType: byte): IServiceQueryResultItem;
1367 procedure PrintBuf; {can be used to print buffer in hex for debugging}
1368 property Items[index: integer]: IServiceQueryResultItem read getItem; default;
1369 property Count: integer read getCount;
1370 end;
1371
1372 IFirebirdLibrary = interface;
1373
1374 {The IServiceManager interface provides access to a service manager. It can
1375 used to Detach and re-attach to Service Manager, to start services and to
1376 query the service manager.
1377
1378 The interface is returned by the FirebirdAPI GetService Manager method.
1379 }
1380
1381 { IServiceManager }
1382
1383 IServiceManager = interface
1384 ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1385 function getFirebirdAPI: IFirebirdAPI;
1386 function getSPB: ISPB;
1387 function getServerName: AnsiString;
1388 function getProtocol: TProtocol;
1389 function getPortNo: AnsiString;
1390 procedure Attach;
1391 procedure Detach(Force: boolean=false);
1392 function IsAttached: boolean;
1393 function AllocateSRB: ISRB;
1394 function AllocateSQPB: ISQPB;
1395 function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1396 function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1397 function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1398 end;
1399
1400 {Tbe Firebird Library API used to get information about the Firebird library}
1401
1402
1403 IFirebirdLibrary = interface
1404 ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1405 function GetHandle: TLibHandle;
1406 function GetLibraryName: string;
1407 function GetLibraryFilePath: string;
1408 function GetFirebirdAPI: IFirebirdAPI;
1409 end;
1410
1411 {The Firebird API.
1412
1413 This is the base interface and is used to create/open a database connection, to
1414 start a transaction on multiple databases and the access the service manager.
1415
1416 The interface is returned by the FirebirdAPI function.
1417 }
1418
1419 { IFirebirdAPI }
1420
1421 IFirebirdAPI = interface
1422 ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1423 {Database connections}
1424 function AllocateDPB: IDPB;
1425 function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1426 function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1427 function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1428
1429 {Start Transaction against multiple databases}
1430 function AllocateTPB: ITPB;
1431 function StartTransaction(Attachments: array of IAttachment;
1432 TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit;
1433 aName: AnsiString=''): ITransaction; overload;
1434 function StartTransaction(Attachments: array of IAttachment;
1435 TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit;
1436 aName: AnsiString=''): ITransaction; overload;
1437
1438 {Service Manager}
1439 function HasServiceAPI: boolean;
1440 function AllocateSPB: ISPB;
1441 function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1442 function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1443
1444 {Information}
1445 function GetStatus: IStatus;
1446 function HasRollbackRetaining: boolean;
1447 function IsEmbeddedServer: boolean;
1448 function GetImplementationVersion: AnsiString;
1449 function GetClientMajor: integer;
1450 function GetClientMinor: integer;
1451 function HasDecFloatSupport: boolean;
1452 function HasLocalTZDB: boolean;
1453 function HasTimeZoneSupport: boolean;
1454 function HasExtendedTZSupport: boolean;
1455
1456 {Firebird 3 API}
1457 function HasMasterIntf: boolean;
1458 function GetIMaster: TObject; deprecated 'Use FirebirdAPI.QueryInterface and FBClientLib.pas IFBIMasterProvider instead';
1459 function GetFBLibrary: IFirebirdLibrary;
1460 end;
1461
1462 type
1463 TOnGetLibraryName = procedure(var libname: string);
1464
1465 const
1466 OnGetLibraryName: TOnGetLibraryName = nil;
1467 AllowUseOfFBLIB: boolean = false;
1468
1469 type
1470 { EIBError }
1471
1472 EIBError = class(EDatabaseError)
1473 private
1474 FSQLCode: Long;
1475 public
1476 constructor Create(ASQLCode: Long; Msg: AnsiString);
1477 property SQLCode: Long read FSQLCode;
1478 end;
1479
1480 { EIBInterBaseError - Firebird Engine errors}
1481
1482 EIBInterBaseError = class(EIBError)
1483 private
1484 FIBErrorCode: Long;
1485 FStatus: IStatus;
1486 public
1487 constructor Create(aStatus: IStatus; CodePage: TSystemCodePage); overload;
1488 constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload;
1489 property IBErrorCode: Long read FIBErrorCode;
1490 property Status: IStatus read FStatus;
1491 end;
1492
1493 {IB Client Exceptions}
1494 EIBClientError = class(EIBError);
1495
1496 {Used to explicitly report a Batch Buffer overflow}
1497 EIBBatchBufferOverflow = class(EIBError);
1498
1499 {The Firebird API function is used to access the IFirebirdAPI interface.
1500
1501 It will load the Firebird Client Library if this is not already loaded and
1502 select an implementation of the Firebird API (legacy 2.5 or 3.0.
1503 }
1504
1505 function FirebirdAPI: IFirebirdAPI;
1506
1507 {IBX support functions. Probably best ignored i.e. always used the FirebirdAPI
1508 function to load the library and check if it's loaded.}
1509
1510 function TryIBLoad: Boolean;
1511 procedure CheckIBLoaded;
1512
1513 {If you want to explicitly load the Firebird library from a
1514 non-default location then use this function and its GetFirebirdAPI function
1515 to get the API.}
1516
1517 function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1518
1519 {$if not declared(Null)} {Needed for Delphi}
1520 function Null: Variant; // Null standard constant
1521 {$define NEEDNULLFUNCTION}
1522 {$ifend}
1523
1524 implementation
1525
1526 uses FBClientAPI {$if not declared(NULL)}, Variants {$ifend}
1527 {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1528 {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1529
1530 var FDefaultFBLibrary: IFirebirdLibrary;
1531
1532 type
1533
1534 { TFBLibrary }
1535
1536 TFBLibraryImpl = class(TFBLibrary)
1537 protected
1538 function GetFirebird3API: IFirebirdAPI; override;
1539 function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1540 end;
1541
1542 function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1543 begin
1544 {$IFDEF USEFIREBIRD3API}
1545 Result := TFB30ClientAPI.Create(self);
1546 {$ELSE}
1547 Result := nil;
1548 {$ENDIF}
1549 end;
1550
1551 function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1552 begin
1553 {$IFDEF USELEGACYFIREBIRDAPI}
1554 Result := TFB25ClientAPI.Create(self);
1555 {$ELSE}
1556 Result := nil;
1557 {$ENDIF}
1558 end;
1559
1560 function FirebirdAPI: IFirebirdAPI;
1561 begin
1562 if FDefaultFBLibrary = nil then
1563 CheckIBLoaded;
1564 Result := FDefaultFBLibrary.GetFirebirdAPI;
1565 end;
1566
1567 function TryIBLoad: Boolean;
1568 var fblib: IFirebirdLibrary;
1569 begin
1570 Result := FDefaultFBLibrary <> nil;
1571 try
1572 if not Result then
1573 begin
1574 fblib := TFBLibraryImpl.Create;
1575 if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1576 FDefaultFBLibrary := fblib;
1577 Result := FDefaultFBLibrary <> nil;
1578 end;
1579 except
1580 SysUtils.showexception(ExceptObject,ExceptAddr);
1581 Result := false;
1582 end;
1583 end;
1584
1585 procedure CheckIBLoaded;
1586 begin
1587 if not TryIBLoad then
1588 IBError(ibxeInterBaseMissing, [nil]);
1589 end;
1590
1591 function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1592 var fblib: IFirebirdLibrary;
1593 begin
1594 if trim(aLibPathName) = '' then
1595 begin
1596 CheckIBLoaded;
1597 Result := FDefaultFBLibrary;
1598 end
1599 else
1600 begin
1601 fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1602 if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1603 IBError(ibxeInterBaseMissing, [nil]);
1604 Result := fblib;
1605 end;
1606 end;
1607
1608 { EIBError }
1609
1610 constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
1611 begin
1612 inherited Create(Msg);
1613 FSQLCode := ASQLCode;
1614 end;
1615
1616 { EIBInterBaseError }
1617
1618 constructor EIBInterBaseError.Create(aStatus: IStatus; CodePage: TSystemCodePage
1619 );
1620 begin
1621 inherited Create(aStatus.Getsqlcode,aStatus.GetMessage(CodePage));
1622 FIBErrorCode := aStatus.GetIBErrorCode;
1623 FStatus := aStatus.Clone;
1624 end;
1625
1626 constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long;
1627 Msg: AnsiString);
1628 begin
1629 inherited Create(ASQLCode,Msg);
1630 FIBErrorCode := AIBErrorCode;
1631 end;
1632
1633 {$ifdef NEEDNULLFUNCTION}
1634 function Null: Variant; // Null standard constant
1635 begin
1636 VarClearProc(TVarData(Result));
1637 TVarData(Result).VType := varnull;
1638 end;
1639 {$endif}
1640
1641 initialization
1642 FDefaultFBLibrary := nil;
1643
1644 finalization
1645 FDefaultFBLibrary := nil;
1646
1647 end.
1648

Properties

Name Value
svn:eol-style native