ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/IB.pas
Revision: 390
Committed: Sat Jan 22 16:15:12 2022 UTC (2 years, 3 months ago) by tony
Content type: text/x-pascal
File size: 69189 byte(s)
Log Message:
In Firebird 3 and later API: the status vector is now a thread var

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

Properties

Name Value
svn:eol-style native