60 |
|
{ } |
61 |
|
{************************************************************************} |
62 |
|
unit IB; |
63 |
+ |
{$IFDEF MSWINDOWS} |
64 |
+ |
{$DEFINE WINDOWS} |
65 |
+ |
{$ENDIF} |
66 |
|
|
67 |
|
{$IFDEF FPC} |
68 |
< |
{$mode objfpc}{$H+} |
68 |
> |
{$mode delphi} |
69 |
|
{$codepage UTF8} |
70 |
|
{$interfaces COM} |
71 |
< |
{$IF FPC_FULLVERSION < 30000 } |
71 |
> |
{$IF defined(FPC) and (FPC_FULLVERSION < 30000) } |
72 |
|
{$ERROR FPC Version 3.0.0 or later is required} |
73 |
< |
{$ENDIF} |
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 |
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 |
|
|
126 |
|
interface |
127 |
|
|
128 |
|
uses |
129 |
< |
Classes, SysUtils, DB, FBMessages, IBExternals; |
129 |
> |
Classes, |
130 |
> |
{$IFDEF WINDOWS}Windows, {$ENDIF} |
131 |
> |
{$IFDEF FPC} Dynlibs, {$ENDIF} |
132 |
> |
SysUtils, DB, FBMessages, IBExternals; |
133 |
> |
|
134 |
> |
const |
135 |
> |
{Interface version information} |
136 |
> |
FBIntf_Major = 1; |
137 |
> |
FBIntf_Minor = 1; |
138 |
> |
FBIntf_Release = 5; |
139 |
> |
FBIntf_Version = '1.1.5'; |
140 |
|
|
141 |
|
{These include files are converted from the 'C' originals in the Firebird API |
142 |
|
and define the various constants used by the API} |
143 |
|
|
144 |
< |
{$I consts_pub.inc} |
145 |
< |
{$I inf_pub.inc} |
146 |
< |
{$I configkeys.inc} |
144 |
> |
{$I 'include/consts_pub.inc'} |
145 |
> |
{$I 'include/inf_pub.inc'} |
146 |
> |
{$I 'include/configkeys.inc'} |
147 |
|
|
148 |
|
{The following constants define the values return by calls to the GetSQLType |
149 |
|
methods provided by several of the interfaces defined below.} |
179 |
|
PGDS__QUAD = ^TGDS__QUAD; |
180 |
|
PISC_QUAD = ^TISC_QUAD; |
181 |
|
|
182 |
+ |
{$IFNDEF FPC} |
183 |
+ |
{Delphi missing definitions} |
184 |
+ |
type |
185 |
+ |
TLibHandle = THandle; |
186 |
+ |
|
187 |
+ |
const |
188 |
+ |
NilHandle = 0; |
189 |
+ |
DirectorySeparator = '\'; |
190 |
+ |
|
191 |
+ |
{Delphi only seems to define CP_UTF8 and CP_UTF16} |
192 |
+ |
const |
193 |
+ |
CP_ACP = 0; // default to ANSI code page |
194 |
+ |
CP_OEMCP = 1; // default to OEM (console) code page |
195 |
+ |
CP_UTF16BE = 1201; // unicodeFFFE |
196 |
+ |
CP_UTF7 = 65000; // utf-7 |
197 |
+ |
CP_ASCII = 20127; // us-ascii |
198 |
+ |
CP_NONE = $FFFF; // rawbytestring encoding |
199 |
+ |
|
200 |
+ |
{$ENDIF} |
201 |
+ |
|
202 |
+ |
type |
203 |
+ |
{$IF not declared(TSystemCodePage)} |
204 |
+ |
TSystemCodePage = word; {not defined in Delphi} |
205 |
+ |
{$IFEND} |
206 |
+ |
|
207 |
|
TIBSQLStatementTypes = |
208 |
|
(SQLUnknown, SQLSelect, SQLInsert, |
209 |
|
SQLUpdate, SQLDelete, SQLDDL, |
215 |
|
TFBStatusCode = cardinal; |
216 |
|
TByteArray = array of byte; |
217 |
|
|
218 |
+ |
IFirebirdAPI = interface; |
219 |
|
IAttachment = interface; |
220 |
|
ITransaction = interface; |
221 |
|
|
222 |
< |
{The IParameterBlock generic interface provides the template for all parameter |
222 |
> |
{The IParameterBlock interface provides the template for all parameter |
223 |
|
block interfaces} |
224 |
|
|
225 |
< |
generic IParameterBlock<_IItem> = interface |
225 |
> |
IParameterBlock<_IItem> = interface |
226 |
|
function getCount: integer; |
227 |
|
function Add(ParamType: byte): _IItem; |
228 |
|
function getItems(index: integer): _IItem; |
236 |
|
different parameter block items } |
237 |
|
|
238 |
|
IParameterBlockItem = interface |
239 |
+ |
['{53b23f7b-abda-46a5-9aa5-07bd5e723266}'] |
240 |
|
function getParamType: byte; |
241 |
|
function getAsInteger: integer; |
242 |
< |
function getAsString: string; |
242 |
> |
function getAsString: AnsiString; |
243 |
|
function getAsByte: byte; |
244 |
< |
procedure setAsString(aValue: string); |
244 |
> |
procedure setAsString(aValue: AnsiString); |
245 |
|
procedure setAsByte(aValue: byte); |
246 |
|
procedure SetAsInteger(aValue: integer); |
247 |
< |
property AsString: string read getAsString write setAsString; |
247 |
> |
property AsString: AnsiString read getAsString write setAsString; |
248 |
|
property AsByte: byte read getAsByte write setAsByte; |
249 |
|
property AsInteger: integer read getAsInteger write SetAsInteger; |
250 |
|
end; |
258 |
|
} |
259 |
|
|
260 |
|
IStatus = interface |
261 |
+ |
['{34167722-af38-4831-b08a-93162d58ede3}'] |
262 |
|
function GetIBErrorCode: Long; |
263 |
|
function Getsqlcode: Long; |
264 |
< |
function GetMessage: string; |
264 |
> |
function GetMessage: AnsiString; |
265 |
|
function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean; |
266 |
|
function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages; |
267 |
|
procedure SetIBDataBaseErrorMessages(Value: TIBDataBaseErrorMessages); |
278 |
|
TArrayBounds = array of TArrayBound; |
279 |
|
|
280 |
|
IArrayMetaData = interface |
281 |
+ |
['{7dd0aea4-59af-4c2a-b958-565d5025c489}'] |
282 |
|
function GetSQLType: cardinal; |
283 |
< |
function GetSQLTypeName: string; |
283 |
> |
function GetSQLTypeName: AnsiString; |
284 |
|
function GetScale: integer; |
285 |
|
function GetSize: cardinal; |
286 |
|
function GetCharSetID: cardinal; |
287 |
< |
function GetTableName: string; |
288 |
< |
function GetColumnName: string; |
287 |
> |
function GetTableName: AnsiString; |
288 |
> |
function GetColumnName: AnsiString; |
289 |
|
function GetDimensions: integer; |
290 |
|
function GetBounds: TArrayBounds; |
291 |
|
end; |
310 |
|
TArrayEventHandler = procedure(Sender: IArray; Reason: TArrayEventReason) of object; |
311 |
|
|
312 |
|
IArray = interface(IArrayMetaData) |
313 |
+ |
['{631c6bb1-fb49-44fb-a64a-c49859632b88}'] |
314 |
|
function GetArrayID: TISC_QUAD; |
315 |
|
procedure Clear; |
316 |
|
function IsEmpty: boolean; |
326 |
|
function GetAsFloat(index: array of integer): Float; |
327 |
|
function GetAsLong(index: array of integer): Long; |
328 |
|
function GetAsShort(index: array of integer): Short; |
329 |
< |
function GetAsString(index: array of integer): String; |
329 |
> |
function GetAsString(index: array of integer): AnsiString; |
330 |
|
function GetAsVariant(index: array of integer): Variant; |
331 |
|
procedure SetAsInteger(index: array of integer; AValue: integer); |
332 |
|
procedure SetAsBoolean(index: array of integer; AValue: boolean); |
339 |
|
procedure SetAsDouble(index: array of integer; Value: Double); |
340 |
|
procedure SetAsFloat(index: array of integer; Value: Float); |
341 |
|
procedure SetAsShort(index: array of integer; Value: Short); |
342 |
< |
procedure SetAsString(index: array of integer; Value: String); |
342 |
> |
procedure SetAsString(index: array of integer; Value: AnsiString); |
343 |
|
procedure SetAsVariant(index: array of integer; Value: Variant); |
344 |
|
procedure SetBounds(dim, UpperBound, LowerBound: integer); |
345 |
|
function GetAttachment: IAttachment; |
353 |
|
} |
354 |
|
|
355 |
|
IBlobMetaData = interface |
356 |
+ |
['{575f3c61-bb33-46a5-8975-bb7d1b6e37cc}'] |
357 |
|
function GetSubType: integer; |
358 |
|
function GetCharSetID: cardinal; |
359 |
|
function GetCodePage: TSystemCodePage; |
360 |
|
function GetSegmentSize: cardinal; |
361 |
< |
function GetRelationName: string; |
362 |
< |
function GetColumnName: string; |
361 |
> |
function GetRelationName: AnsiString; |
362 |
> |
function GetColumnName: AnsiString; |
363 |
|
end; |
364 |
|
|
365 |
|
{The Blob Parameter block is used to select a Blob Filter} |
366 |
|
|
367 |
< |
IBPBItem = interface (IParameterBlockItem) end; |
367 |
> |
IBPBItem = interface (IParameterBlockItem) |
368 |
> |
['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}'] |
369 |
> |
end; |
370 |
|
|
371 |
< |
IBPB = specialize IParameterBlock<IBPBItem>; |
371 |
> |
IBPB = interface (IParameterBlock<IBPBItem>) |
372 |
> |
['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}'] |
373 |
> |
end; |
374 |
|
|
375 |
|
{ The Blob Interface provides access to a blob data item. |
376 |
|
|
384 |
|
TBlobType = (btSegmented,btStream); |
385 |
|
|
386 |
|
IBlob = interface(IBlobMetaData) |
387 |
+ |
['{3090a145-7780-442b-b15b-efd4568b8611}'] |
388 |
|
function GetBPB: IBPB; |
389 |
|
procedure Cancel; |
390 |
|
procedure Close; |
395 |
|
TotalSize: Int64; var BlobType: TBlobType); |
396 |
|
function Read(var Buffer; Count: Longint): Longint; |
397 |
|
function Write(const Buffer; Count: Longint): Longint; |
398 |
< |
function LoadFromFile(Filename: string): IBlob; |
398 |
> |
function LoadFromFile(Filename: AnsiString): IBlob; |
399 |
|
function LoadFromStream(S: TStream) : IBlob; |
400 |
< |
function SaveToFile(Filename: string): IBlob; |
400 |
> |
function SaveToFile(Filename: AnsiString): IBlob; |
401 |
|
function SaveToStream(S: TStream): IBlob; |
402 |
|
function GetAsString: rawbytestring; |
403 |
|
procedure SetAsString(aValue: rawbytestring); |
411 |
|
the output of an SQL Statement. |
412 |
|
} |
413 |
|
|
414 |
+ |
TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP} |
415 |
+ |
dfDateTime, {SQL DATETIME} |
416 |
+ |
dfTime); {SQL TIME} |
417 |
+ |
|
418 |
|
{ IColumnMetaData } |
419 |
|
|
420 |
|
IColumnMetaData = interface |
421 |
+ |
['{c222e6c3-53c1-469f-9e05-0a5c3ef232d8}'] |
422 |
|
function GetIndex: integer; |
423 |
|
function GetSQLType: cardinal; |
424 |
< |
function GetSQLTypeName: string; |
424 |
> |
function GetSQLTypeName: AnsiString; |
425 |
|
function getSubtype: integer; |
426 |
< |
function getRelationName: string; |
427 |
< |
function getOwnerName: string; |
428 |
< |
function getSQLName: string; {Name of the column} |
429 |
< |
function getAliasName: string; {Alias Name of column or Column Name if no alias} |
430 |
< |
function getName: string; {Disambiguated uppercase Field Name} |
426 |
> |
function getRelationName: AnsiString; |
427 |
> |
function getOwnerName: AnsiString; |
428 |
> |
function getSQLName: AnsiString; {Name of the column} |
429 |
> |
function getAliasName: AnsiString; {Alias Name of column or Column Name if no alias} |
430 |
> |
function getName: AnsiString; {Disambiguated uppercase Field Name} |
431 |
|
function getScale: integer; |
432 |
|
function getCharSetID: cardinal; |
433 |
|
function getCodePage: TSystemCodePage; |
435 |
|
function GetSize: cardinal; |
436 |
|
function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type} |
437 |
|
function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type} |
438 |
< |
property Name: string read GetName; |
438 |
> |
function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer; |
439 |
> |
property Name: AnsiString read GetName; |
440 |
|
property Size: cardinal read GetSize; |
441 |
|
property SQLType: cardinal read GetSQLType; |
442 |
|
property Scale: integer read getScale; |
452 |
|
{ IMetaData } |
453 |
|
|
454 |
|
IMetaData = interface |
455 |
+ |
['{4dafdbb6-0d36-4f1f-9c95-8b132804b965}'] |
456 |
|
function getCount: integer; |
457 |
|
function getColumnMetaData(index: integer): IColumnMetaData; |
458 |
< |
function GetUniqueRelationName: string; {Non empty if all columns come from the same table} |
459 |
< |
function ByName(Idx: String): IColumnMetaData; |
458 |
> |
function GetUniqueRelationName: AnsiString; {Non empty if all columns come from the same table} |
459 |
> |
function ByName(Idx: AnsiString): IColumnMetaData; |
460 |
|
property ColMetaData[index: integer]: IColumnMetaData read getColumnMetaData; default; |
461 |
|
property Count: integer read getCount; |
462 |
|
end; |
476 |
|
|
477 |
|
|
478 |
|
ISQLData = interface(IColumnMetaData) |
479 |
+ |
['{3f493e31-7e3f-4606-a07c-b210b9e3619d}'] |
480 |
|
function GetAsBoolean: boolean; |
481 |
|
function GetAsCurrency: Currency; |
482 |
|
function GetAsInt64: Int64; |
487 |
|
function GetAsPointer: Pointer; |
488 |
|
function GetAsQuad: TISC_QUAD; |
489 |
|
function GetAsShort: short; |
490 |
< |
function GetAsString: String; |
490 |
> |
function GetAsString: AnsiString; |
491 |
|
function GetIsNull: Boolean; |
492 |
|
function GetAsVariant: Variant; |
493 |
|
function GetAsBlob: IBlob; overload; |
506 |
|
property AsPointer: Pointer read GetAsPointer; |
507 |
|
property AsQuad: TISC_QUAD read GetAsQuad; |
508 |
|
property AsShort: short read GetAsShort; |
509 |
< |
property AsString: String read GetAsString; |
509 |
> |
property AsString: AnsiString read GetAsString; |
510 |
|
property AsVariant: Variant read GetAsVariant ; |
511 |
|
property AsBlob: IBlob read GetAsBlob; |
512 |
|
property AsArray: IArray read GetAsArray; |
521 |
|
} |
522 |
|
|
523 |
|
IResults = interface |
524 |
+ |
['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}'] |
525 |
|
function getCount: integer; |
526 |
|
function GetTransaction: ITransaction; |
527 |
< |
function ByName(Idx: String): ISQLData; |
527 |
> |
function ByName(Idx: AnsiString): ISQLData; |
528 |
|
function getSQLData(index: integer): ISQLData; |
529 |
< |
procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar); |
529 |
> |
procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte); |
530 |
|
procedure SetRetainInterfaces(aValue: boolean); |
531 |
|
property Data[index: integer]: ISQLData read getSQLData; default; |
532 |
|
property Count: integer read getCount; |
538 |
|
in turn, used to access the data returned by each field of the current row. |
539 |
|
} |
540 |
|
IResultSet = interface(IResults) |
541 |
+ |
['{0ae4979b-7857-4e8c-8918-ec6f155b51a0}'] |
542 |
|
function FetchNext: boolean; |
543 |
< |
function GetCursorName: string; |
543 |
> |
function GetCursorName: AnsiString; |
544 |
|
function IsEof: boolean; |
545 |
|
procedure Close; |
546 |
|
end; |
561 |
|
} |
562 |
|
|
563 |
|
ISQLParam = interface |
564 |
+ |
['{b22b4578-6d41-4807-a9a9-d2ec8d1d5a14}'] |
565 |
|
function GetIndex: integer; |
566 |
|
function GetSQLType: cardinal; |
567 |
< |
function GetSQLTypeName: string; |
567 |
> |
function GetSQLTypeName: AnsiString; |
568 |
|
function getSubtype: integer; |
569 |
< |
function getName: string; |
569 |
> |
function getName: AnsiString; |
570 |
|
function getScale: integer; |
571 |
|
function getCharSetID: cardinal; |
572 |
|
function getCodePage: TSystemCodePage; |
582 |
|
function GetAsPointer: Pointer; |
583 |
|
function GetAsQuad: TISC_QUAD; |
584 |
|
function GetAsShort: short; |
585 |
< |
function GetAsString: String; |
585 |
> |
function GetAsString: AnsiString; |
586 |
|
function GetIsNull: boolean; |
587 |
|
function GetAsVariant: Variant; |
588 |
|
function GetAsBlob: IBlob; |
600 |
|
procedure SetAsFloat(aValue: Float); |
601 |
|
procedure SetAsPointer(aValue: Pointer); |
602 |
|
procedure SetAsShort(aValue: Short); |
603 |
< |
procedure SetAsString(aValue: String); |
603 |
> |
procedure SetAsString(aValue: AnsiString); |
604 |
|
procedure SetAsVariant(aValue: Variant); |
605 |
|
procedure SetIsNull(aValue: Boolean); |
606 |
|
procedure SetAsBlob(aValue: IBlob); |
619 |
|
property AsLong: Long read GetAsLong write SetAsLong; |
620 |
|
property AsPointer: Pointer read GetAsPointer write SetAsPointer; |
621 |
|
property AsShort: Short read GetAsShort write SetAsShort; |
622 |
< |
property AsString: String read GetAsString write SetAsString; |
622 |
> |
property AsString: AnsiString read GetAsString write SetAsString; |
623 |
|
property AsVariant: Variant read GetAsVariant write SetAsVariant; |
624 |
|
property AsBlob: IBlob read GetAsBlob write SetAsBlob; |
625 |
|
property AsArray: IArray read GetAsArray write SetAsArray; |
628 |
|
property IsNull: Boolean read GetIsNull write SetIsNull; |
629 |
|
property IsNullable: Boolean read GetIsNullable; |
630 |
|
property Modified: Boolean read getModified; |
631 |
< |
property Name: string read GetName; |
631 |
> |
property Name: AnsiString read GetName; |
632 |
|
property SQLType: cardinal read GetSQLType; |
633 |
|
end; |
634 |
|
|
638 |
|
} |
639 |
|
|
640 |
|
ISQLParams = interface |
641 |
+ |
['{c6d95ac7-b2b7-461b-b890-afef0acbb077}'] |
642 |
|
function getCount: integer; |
643 |
|
function getSQLParam(index: integer): ISQLParam; |
644 |
< |
function ByName(Idx: String): ISQLParam ; |
644 |
> |
function ByName(Idx: AnsiString): ISQLParam ; |
645 |
|
function GetModified: Boolean; |
646 |
+ |
function GetHasCaseSensitiveParams: Boolean; |
647 |
|
property Modified: Boolean read GetModified; |
648 |
|
property Params[index: integer]: ISQLParam read getSQLParam; default; |
649 |
|
property Count: integer read getCount; |
650 |
|
end; |
651 |
|
|
652 |
+ |
|
653 |
+ |
TPerfStats = (psCurrentMemory, psMaxMemory, |
654 |
+ |
psRealTime, psUserTime, psBuffers, |
655 |
+ |
psReads, psWrites, psFetches,psDeltaMemory); |
656 |
+ |
|
657 |
+ |
TPerfCounters = array[TPerfStats] of Int64; |
658 |
+ |
|
659 |
|
{The IStatement interface provides access to an SQL Statement once it has been |
660 |
|
initially prepared. The interface is returned from the IAttachment interface. |
661 |
|
} |
662 |
|
|
663 |
|
IStatement = interface |
664 |
+ |
['{a260576d-a07d-4a66-b02d-1b72543fd7cf}'] |
665 |
|
function GetMetaData: IMetaData; {Output Metadata} |
666 |
|
function GetSQLParams: ISQLParams;{Statement Parameters} |
667 |
< |
function GetPlan: String; |
667 |
> |
function GetPlan: AnsiString; |
668 |
|
function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean; |
669 |
|
function GetSQLStatementType: TIBSQLStatementTypes; |
670 |
< |
function GetSQLText: string; |
670 |
> |
function GetSQLText: AnsiString; |
671 |
> |
function GetProcessedSQLText: AnsiString; |
672 |
|
function GetSQLDialect: integer; |
673 |
|
function IsPrepared: boolean; |
674 |
|
procedure Prepare(aTransaction: ITransaction=nil); |
677 |
|
function GetAttachment: IAttachment; |
678 |
|
function GetTransaction: ITransaction; |
679 |
|
procedure SetRetainInterfaces(aValue: boolean); |
680 |
+ |
procedure EnableStatistics(aValue: boolean); |
681 |
+ |
function GetPerfStatistics(var stats: TPerfCounters): boolean; |
682 |
|
property MetaData: IMetaData read GetMetaData; |
683 |
|
property SQLParams: ISQLParams read GetSQLParams; |
684 |
|
property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType; |
695 |
|
found in the Interbase 6.0 API Guide. |
696 |
|
} |
697 |
|
|
698 |
< |
ITPBItem = interface(IParameterBlockItem) end; |
698 |
> |
ITPBItem = interface(IParameterBlockItem) |
699 |
> |
['{544c1f2b-7c12-4a87-a4a5-face7ea72671}'] |
700 |
> |
end; |
701 |
|
|
702 |
< |
ITPB = specialize IParameterBlock<ITPBItem>; |
702 |
> |
ITPB = interface(IParameterBlock<ITPBItem>) |
703 |
> |
['{7369b0ff-defe-437b-81fe-19b211d42d25}'] |
704 |
> |
end; |
705 |
|
|
706 |
|
{The ITransactionAction interface provides access to a Transaction once it |
707 |
|
has been initially started. After a Commit or Rollback, a transaction |
715 |
|
TTransactionCompletion = TARollback.. TACommit; |
716 |
|
|
717 |
|
ITransaction = interface |
718 |
+ |
['{30928d0e-a9d7-4c61-b7cf-14f4f38abe2a}'] |
719 |
|
function getTPB: ITPB; |
720 |
|
procedure Start(DefaultCompletion: TTransactionCompletion=taCommit); |
721 |
|
function GetInTransaction: boolean; |
743 |
|
} |
744 |
|
|
745 |
|
TEventInfo = record |
746 |
< |
EventName: string; |
746 |
> |
EventName: AnsiString; |
747 |
|
Count: integer; |
748 |
|
end; |
749 |
|
|
754 |
|
{ IEvents } |
755 |
|
|
756 |
|
IEvents = interface |
757 |
+ |
['{6a0be233-ed08-4524-889c-2e45d0c20e5f}'] |
758 |
|
procedure GetEvents(EventNames: TStrings); |
759 |
|
procedure SetEvents(EventNames: TStrings); overload; |
760 |
< |
procedure SetEvents(EventName: string); overload; |
760 |
> |
procedure SetEvents(EventName: AnsiString); overload; |
761 |
|
procedure Cancel; |
762 |
|
function ExtractEventCounts: TEventCounts; |
763 |
|
procedure WaitForEvent; |
788 |
|
TDBOperationCounts = array of TDBOperationCount; |
789 |
|
|
790 |
|
IDBInfoItem = interface |
791 |
+ |
['{eeb97b51-ec0f-473f-9f75-c1721f055fcb}'] |
792 |
|
function getItemType: byte; |
793 |
|
function getSize: integer; |
794 |
|
procedure getRawBytes(var Buffer); |
795 |
< |
function getAsString: string; |
795 |
> |
function getAsString: AnsiString; |
796 |
|
function getAsInteger: integer; |
797 |
< |
procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: string); |
797 |
> |
procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString); |
798 |
|
function getAsBytes: TByteArray; |
799 |
< |
procedure DecodeVersionString(var Version: byte; var VersionString: string); |
799 |
> |
function getAsDateTime: TDateTime; |
800 |
> |
procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString); |
801 |
|
function getOperationCounts: TDBOperationCounts; |
802 |
|
procedure DecodeUserNames(UserNames: TStrings); |
803 |
|
|
806 |
|
function GetItem(index: integer): IDBInfoItem; |
807 |
|
function Find(ItemType: byte): IDBInfoItem; |
808 |
|
property AsInteger: integer read getAsInteger; |
809 |
< |
property AsString: string read GetAsString; |
809 |
> |
property AsString: AnsiString read GetAsString; |
810 |
|
property Count: integer read GetCount; |
811 |
|
property Items[index: integer]: IDBInfoItem read getItem; default; |
812 |
|
end; |
814 |
|
{ IDBInformation } |
815 |
|
|
816 |
|
IDBInformation = interface |
817 |
+ |
['{7ac6777f-f0a9-498a-9f5c-4a57a554df81}'] |
818 |
|
function GetCount: integer; |
819 |
|
function GetItem(index: integer): IDBInfoItem; |
820 |
|
function Find(ItemType: byte): IDBInfoItem; |
823 |
|
property Items[index: integer]: IDBInfoItem read getItem; default; |
824 |
|
end; |
825 |
|
|
826 |
+ |
{The Database Information Request Block is used to pass requests for |
827 |
+ |
database information where at least one item requested has a parameter. |
828 |
+ |
At present, this is only fb_info_page_contents which has a single |
829 |
+ |
integer parameter.} |
830 |
+ |
|
831 |
+ |
IDIRBItem = interface(IParameterBlockItem) |
832 |
+ |
['{d34a7511-8435-4a24-81a7-5103d218d234}'] |
833 |
+ |
end; |
834 |
+ |
|
835 |
+ |
IDIRB = interface(IParameterBlock<IDIRBItem>) |
836 |
+ |
['{1010e5ac-0a8f-403b-a302-91625e9d9579}'] |
837 |
+ |
end; |
838 |
+ |
|
839 |
+ |
|
840 |
|
{The Database Parameter Block (DPB). |
841 |
|
|
842 |
|
The DPB provides the parameters used when connecting to a database. It is allocated |
848 |
|
found in the Interbase 6.0 API Guide. |
849 |
|
} |
850 |
|
|
851 |
< |
IDPBItem = interface(IParameterBlockItem) end; |
851 |
> |
IDPBItem = interface(IParameterBlockItem) |
852 |
> |
['{123d4ad0-087a-4cd1-a344-1b3d03b30673}'] |
853 |
> |
end; |
854 |
|
|
855 |
< |
IDPB = specialize IParameterBlock<IDPBItem>; |
855 |
> |
IDPB = interface(IParameterBlock<IDPBItem>) |
856 |
> |
['{e676067b-1cf4-4eba-9256-9724f57e0d16}'] |
857 |
> |
end; |
858 |
|
|
859 |
|
{The IAttachment interface provides access to a Database Connection. It may be |
860 |
|
used to: |
884 |
|
{ IAttachment } |
885 |
|
|
886 |
|
IAttachment = interface |
887 |
+ |
['{466e9b67-9def-4807-b3e7-e08a35e7185c}'] |
888 |
+ |
function getFirebirdAPI: IFirebirdAPI; |
889 |
|
function getDPB: IDPB; |
890 |
|
function AllocateBPB: IBPB; |
891 |
+ |
function AllocateDIRB: IDIRB; |
892 |
|
procedure Connect; |
893 |
|
procedure Disconnect(Force: boolean=false); |
894 |
|
function IsConnected: boolean; |
895 |
|
procedure DropDatabase; |
896 |
|
function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload; |
897 |
|
function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload; |
898 |
< |
procedure ExecImmediate(transaction: ITransaction; sql: string; SQLDialect: integer); overload; |
899 |
< |
procedure ExecImmediate(TPB: array of byte; sql: string; SQLDialect: integer); overload; |
900 |
< |
procedure ExecImmediate(transaction: ITransaction; sql: string); overload; |
901 |
< |
procedure ExecImmediate(TPB: array of byte; sql: string); overload; |
902 |
< |
function ExecuteSQL(TPB: array of byte; sql: string; SQLDialect: integer; params: array of const): IResults; overload; |
903 |
< |
function ExecuteSQL(transaction: ITransaction; sql: string; SQLDialect: integer; params: array of const): IResults; overload; |
904 |
< |
function ExecuteSQL(TPB: array of byte; sql: string; params: array of const): IResults; overload; |
905 |
< |
function ExecuteSQL(transaction: ITransaction; sql: string; params: array of const): IResults; overload; |
906 |
< |
function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload; |
907 |
< |
function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer; |
898 |
> |
procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; SQLDialect: integer); overload; |
899 |
> |
procedure ExecImmediate(TPB: array of byte; sql: AnsiString; SQLDialect: integer); overload; |
900 |
> |
procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload; |
901 |
> |
procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload; |
902 |
> |
function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload; |
903 |
> |
function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload; |
904 |
> |
function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload; |
905 |
> |
function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload; |
906 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload; |
907 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; |
908 |
|
params: array of const): IResultSet; overload; |
909 |
< |
function OpenCursor(transaction: ITransaction; sql: string): IResultSet; overload; |
910 |
< |
function OpenCursor(transaction: ITransaction; sql: string; |
909 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString): IResultSet; overload; |
910 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; |
911 |
|
params: array of const): IResultSet; overload; |
912 |
< |
function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload; |
913 |
< |
function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer; |
912 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload; |
913 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; |
914 |
|
params: array of const): IResultSet; overload; |
915 |
< |
function OpenCursorAtStart(transaction: ITransaction; sql: string): IResultSet; overload; |
916 |
< |
function OpenCursorAtStart(transaction: ITransaction; sql: string; |
915 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString): IResultSet; overload; |
916 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; |
917 |
|
params: array of const): IResultSet; overload; |
918 |
< |
function OpenCursorAtStart(sql: string): IResultSet; overload; |
919 |
< |
function OpenCursorAtStart(sql: string; |
918 |
> |
function OpenCursorAtStart(sql: AnsiString): IResultSet; overload; |
919 |
> |
function OpenCursorAtStart(sql: AnsiString; |
920 |
|
params: array of const): IResultSet; overload; |
921 |
< |
function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; overload; |
922 |
< |
function Prepare(transaction: ITransaction; sql: string): IStatement; overload; |
923 |
< |
function PrepareWithNamedParameters(transaction: ITransaction; sql: string; |
924 |
< |
aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload; |
925 |
< |
function PrepareWithNamedParameters(transaction: ITransaction; sql: string; |
926 |
< |
GenerateParamNames: boolean=false): IStatement; overload; |
921 |
> |
function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload; |
922 |
> |
function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload; |
923 |
> |
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
924 |
> |
aSQLDialect: integer; GenerateParamNames: boolean=false; |
925 |
> |
CaseSensitiveParams: boolean = false): IStatement; overload; |
926 |
> |
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
927 |
> |
GenerateParamNames: boolean=false; |
928 |
> |
CaseSensitiveParams: boolean = false): IStatement; overload; |
929 |
|
|
930 |
|
{Events} |
931 |
|
function GetEventHandler(Events: TStrings): IEvents; overload; |
932 |
< |
function GetEventHandler(Event: string): IEvents; overload; |
932 |
> |
function GetEventHandler(Event: AnsiString): IEvents; overload; |
933 |
|
|
934 |
|
{Blob - may use to open existing Blobs. However, ISQLData.AsBlob is preferred} |
935 |
|
|
936 |
< |
function CreateBlob(transaction: ITransaction; RelationName, ColumnName: string; BPB: IBPB=nil): IBlob; overload; |
936 |
> |
function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload; |
937 |
|
function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload; |
938 |
|
function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload; |
939 |
< |
function OpenBlob(transaction: ITransaction; RelationName, ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; |
939 |
> |
function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; |
940 |
|
|
941 |
|
{Array - may use to open existing arrays. However, ISQLData.AsArray is preferred} |
942 |
|
|
943 |
< |
function OpenArray(transaction: ITransaction; RelationName, ColumnName: string; ArrayID: TISC_QUAD): IArray; |
944 |
< |
function CreateArray(transaction: ITransaction; RelationName, ColumnName: string): IArray; overload; |
943 |
> |
function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; |
944 |
> |
function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload; |
945 |
|
function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload; |
946 |
+ |
function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString; |
947 |
+ |
Scale: integer; size: cardinal; charSetID: cardinal; dimensions: cardinal; |
948 |
+ |
bounds: TArrayBounds): IArrayMetaData; |
949 |
|
|
950 |
|
{Database Information} |
951 |
|
function GetSQLDialect: integer; |
952 |
< |
function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: string): IBlobMetaData; |
953 |
< |
function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: string): IArrayMetaData; |
952 |
> |
function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData; |
953 |
> |
function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData; |
954 |
|
function GetDBInformation(Requests: array of byte): IDBInformation; overload; |
955 |
|
function GetDBInformation(Request: byte): IDBInformation; overload; |
956 |
+ |
function GetDBInformation(Requests: IDIRB): IDBInformation; overload; |
957 |
+ |
function GetConnectString: AnsiString; |
958 |
+ |
function GetRemoteProtocol: AnsiString; |
959 |
+ |
function GetAuthenticationMethod: AnsiString; |
960 |
+ |
function GetSecurityDatabase: AnsiString; |
961 |
+ |
function GetODSMajorVersion: integer; |
962 |
+ |
function GetODSMinorVersion: integer; |
963 |
+ |
procedure getFBVersion(version: TStrings); |
964 |
|
function HasActivity: boolean; |
965 |
+ |
|
966 |
+ |
{Character Sets} |
967 |
+ |
function HasDefaultCharSet: boolean; |
968 |
+ |
function GetDefaultCharSetID: integer; |
969 |
+ |
function GetCharsetName(CharSetID: integer): AnsiString; |
970 |
+ |
function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean; |
971 |
+ |
function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean; |
972 |
+ |
function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean; |
973 |
+ |
function CharSetWidth(CharSetID: integer; var Width: integer): boolean; |
974 |
+ |
procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage; |
975 |
+ |
AllowReverseLookup:boolean; out CharSetID: integer); |
976 |
|
end; |
977 |
|
|
978 |
< |
TProtocol = (TCP, SPX, NamedPipe, Local); |
978 |
> |
TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol); |
979 |
> |
TProtocol = TCP..xnet; |
980 |
|
|
981 |
|
{Service Parameter Block (SPB). |
982 |
|
|
990 |
|
|
991 |
|
} |
992 |
|
|
993 |
< |
ISPBItem = interface(IParameterBlockItem) end; |
993 |
> |
ISPBItem = interface(IParameterBlockItem) |
994 |
> |
['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}'] |
995 |
> |
end; |
996 |
|
|
997 |
< |
ISPB = specialize IParameterBlock<ISPBItem>; |
997 |
> |
ISPB = interface(IParameterBlock<ISPBItem>) |
998 |
> |
['{2c5836fd-41ed-4426-9b7d-5af580ec2659}'] |
999 |
> |
end; |
1000 |
|
|
1001 |
|
{Service Query Parameter Block (SQPB). |
1002 |
|
|
1005 |
|
} |
1006 |
|
|
1007 |
|
ISQPBItem = interface(IParameterBlockItem) |
1008 |
+ |
['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}'] |
1009 |
|
function CopyFrom(source: TStream; count: integer): integer; |
1010 |
|
end; |
1011 |
|
|
1012 |
< |
ISQPB = specialize IParameterBlock<ISQPBItem>; |
1012 |
> |
ISQPB = interface(IParameterBlock<ISQPBItem>) |
1013 |
> |
['{8553e66b-ee62-498b-8431-dff030211447}'] |
1014 |
> |
end; |
1015 |
|
|
1016 |
|
{Service Request Block (SRB). |
1017 |
|
|
1025 |
|
|
1026 |
|
} |
1027 |
|
|
1028 |
< |
ISRBItem = interface(IParameterBlockItem) end; |
1028 |
> |
ISRBItem = interface(IParameterBlockItem) |
1029 |
> |
['{47ec790e-f265-4b30-9dcd-261e51677245}'] |
1030 |
> |
end; |
1031 |
|
|
1032 |
< |
ISRB = specialize IParameterBlock<ISRBItem>; |
1032 |
> |
ISRB = interface(IParameterBlock<ISRBItem>) |
1033 |
> |
['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}'] |
1034 |
> |
end; |
1035 |
|
|
1036 |
|
{The Service Query Results Interface. |
1037 |
|
|
1049 |
|
} |
1050 |
|
|
1051 |
|
IServiceQueryResultSubItem = interface |
1052 |
+ |
['{8a4c381e-9923-4cc9-a96b-553729248640}'] |
1053 |
|
function getItemType: byte; |
1054 |
|
function getSize: integer; |
1055 |
|
procedure getRawBytes(var Buffer); |
1056 |
< |
function getAsString: string; |
1056 |
> |
function getAsString: AnsiString; |
1057 |
|
function getAsInteger: integer; |
1058 |
|
function getAsByte: byte; |
1059 |
|
function CopyTo(stream: TStream; count: integer): integer; |
1060 |
< |
property AsString: string read getAsString; |
1060 |
> |
property AsString: AnsiString read getAsString; |
1061 |
|
property AsInteger: integer read getAsInteger; |
1062 |
|
property AsByte: byte read getAsByte; |
1063 |
|
end; |
1064 |
|
|
1065 |
|
IServiceQueryResultItem = interface(IServiceQueryResultSubItem) |
1066 |
+ |
['{b2806886-206c-4024-8df9-5fe0a7630a5e}'] |
1067 |
|
function getCount: integer; |
1068 |
|
function getItem(index: integer): IServiceQueryResultSubItem; |
1069 |
|
function find(ItemType: byte): IServiceQueryResultSubItem; |
1072 |
|
end; |
1073 |
|
|
1074 |
|
IServiceQueryResults = interface |
1075 |
+ |
['{8fbbef7d-fe03-4409-828a-a787d34ef531}'] |
1076 |
|
function getCount: integer; |
1077 |
|
function getItem(index: integer): IServiceQueryResultItem; |
1078 |
|
function find(ItemType: byte): IServiceQueryResultItem; |
1081 |
|
property Count: integer read getCount; |
1082 |
|
end; |
1083 |
|
|
1084 |
+ |
IFirebirdLibrary = interface; |
1085 |
+ |
|
1086 |
|
{The IServiceManager interface provides access to a service manager. It can |
1087 |
|
used to Detach and re-attach to Service Manager, to start services and to |
1088 |
|
query the service manager. |
1093 |
|
{ IServiceManager } |
1094 |
|
|
1095 |
|
IServiceManager = interface |
1096 |
+ |
['{905b587d-1e1f-4e40-a3f8-a3519f852e48}'] |
1097 |
+ |
function getFirebirdAPI: IFirebirdAPI; |
1098 |
|
function getSPB: ISPB; |
1099 |
< |
function getServerName: string; |
1099 |
> |
function getServerName: AnsiString; |
1100 |
> |
function getProtocol: TProtocol; |
1101 |
> |
function getPortNo: AnsiString; |
1102 |
|
procedure Attach; |
1103 |
|
procedure Detach(Force: boolean=false); |
1104 |
|
function IsAttached: boolean; |
1105 |
|
function AllocateSRB: ISRB; |
1106 |
|
function AllocateSQPB: ISQPB; |
1107 |
< |
procedure Start(Request: ISRB); |
1108 |
< |
function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload; |
1109 |
< |
function Query(Request: ISRB) :IServiceQueryResults; overload; |
1107 |
> |
function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean; |
1108 |
> |
function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload; |
1109 |
> |
function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload; |
1110 |
> |
end; |
1111 |
> |
|
1112 |
> |
{Tbe Firebird Library API used to get information about the Firebird library} |
1113 |
> |
|
1114 |
> |
|
1115 |
> |
IFirebirdLibrary = interface |
1116 |
> |
['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}'] |
1117 |
> |
function GetHandle: TLibHandle; |
1118 |
> |
function GetLibraryName: string; |
1119 |
> |
function GetLibraryFilePath: string; |
1120 |
> |
function GetFirebirdAPI: IFirebirdAPI; |
1121 |
|
end; |
1122 |
|
|
1123 |
|
{The Firebird API. |
1129 |
|
} |
1130 |
|
|
1131 |
|
IFirebirdAPI = interface |
1132 |
+ |
['{edeee691-c8d3-4dcf-a780-cd7e432821d5}'] |
1133 |
|
{Database connections} |
1134 |
|
function AllocateDPB: IDPB; |
1135 |
< |
function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment; |
1136 |
< |
function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; |
1135 |
> |
function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment; |
1136 |
> |
function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload; |
1137 |
> |
function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload; |
1138 |
|
|
1139 |
|
{Start Transaction against multiple databases} |
1140 |
|
function AllocateTPB: ITPB; |
1146 |
|
{Service Manager} |
1147 |
|
function HasServiceAPI: boolean; |
1148 |
|
function AllocateSPB: ISPB; |
1149 |
< |
function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager; |
1149 |
> |
function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload; |
1150 |
> |
function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload; |
1151 |
|
|
1152 |
|
{Information} |
1153 |
|
function GetStatus: IStatus; |
986 |
– |
function GetLibraryName: string; |
1154 |
|
function HasRollbackRetaining: boolean; |
1155 |
|
function IsEmbeddedServer: boolean; |
1156 |
< |
function GetImplementationVersion: string; |
1156 |
> |
function GetImplementationVersion: AnsiString; |
1157 |
|
|
1158 |
|
{Firebird 3 API} |
1159 |
|
function HasMasterIntf: boolean; |
1160 |
|
function GetIMaster: TObject; |
1161 |
< |
|
995 |
< |
{utility} |
996 |
< |
function GetCharsetName(CharSetID: integer): string; |
997 |
< |
function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean; |
998 |
< |
function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean; |
999 |
< |
function CharSetName2CharSetID(CharSetName: string; var CharSetID: integer): boolean; |
1000 |
< |
function CharSetWidth(CharSetID: integer; var Width: integer): boolean; |
1161 |
> |
function GetFBLibrary: IFirebirdLibrary; |
1162 |
|
end; |
1163 |
|
|
1164 |
|
type |
1175 |
|
private |
1176 |
|
FSQLCode: Long; |
1177 |
|
public |
1178 |
< |
constructor Create(ASQLCode: Long; Msg: string); |
1178 |
> |
constructor Create(ASQLCode: Long; Msg: AnsiString); |
1179 |
|
property SQLCode: Long read FSQLCode; |
1180 |
|
end; |
1181 |
|
|
1186 |
|
FIBErrorCode: Long; |
1187 |
|
public |
1188 |
|
constructor Create(Status: IStatus); overload; |
1189 |
< |
constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: string); overload; |
1189 |
> |
constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload; |
1190 |
|
property IBErrorCode: Long read FIBErrorCode; |
1191 |
|
end; |
1192 |
|
|
1211 |
|
function TryIBLoad: Boolean; |
1212 |
|
procedure CheckIBLoaded; |
1213 |
|
|
1214 |
+ |
{If you want to explicitly load the Firebird library from a |
1215 |
+ |
non-default location then use this function and its GetFirebirdAPI function |
1216 |
+ |
to get the API.} |
1217 |
+ |
|
1218 |
+ |
function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary; |
1219 |
+ |
|
1220 |
|
implementation |
1221 |
|
|
1222 |
|
uses FBClientAPI |
1223 |
|
{$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF} |
1224 |
|
{$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF}; |
1225 |
|
|
1226 |
< |
var FFirebirdAPI: IFirebirdAPI; |
1226 |
> |
var FDefaultFBLibrary: IFirebirdLibrary; |
1227 |
> |
|
1228 |
> |
type |
1229 |
> |
|
1230 |
> |
{ TFBLibrary } |
1231 |
> |
|
1232 |
> |
TFBLibraryImpl = class(TFBLibrary) |
1233 |
> |
protected |
1234 |
> |
function GetFirebird3API: IFirebirdAPI; override; |
1235 |
> |
function GetLegacyFirebirdAPI: IFirebirdAPI; override; |
1236 |
> |
end; |
1237 |
> |
|
1238 |
> |
function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI; |
1239 |
> |
begin |
1240 |
> |
{$IFDEF USEFIREBIRD3API} |
1241 |
> |
Result := TFB30ClientAPI.Create(self); |
1242 |
> |
{$ELSE} |
1243 |
> |
Result := nil; |
1244 |
> |
{$ENDIF} |
1245 |
> |
end; |
1246 |
> |
|
1247 |
> |
function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI; |
1248 |
> |
begin |
1249 |
> |
{$IFDEF USELEGACYFIREBIRDAPI} |
1250 |
> |
Result := TFB25ClientAPI.Create(self); |
1251 |
> |
{$ELSE} |
1252 |
> |
Result := nil; |
1253 |
> |
{$ENDIF} |
1254 |
> |
end; |
1255 |
|
|
1256 |
|
function FirebirdAPI: IFirebirdAPI; |
1257 |
|
begin |
1258 |
< |
if FFirebirdAPI = nil then |
1258 |
> |
if FDefaultFBLibrary = nil then |
1259 |
|
CheckIBLoaded; |
1260 |
< |
Result := FFirebirdAPI; |
1260 |
> |
Result := FDefaultFBLibrary.GetFirebirdAPI; |
1261 |
|
end; |
1262 |
|
|
1263 |
|
function TryIBLoad: Boolean; |
1264 |
+ |
var fblib: IFirebirdLibrary; |
1265 |
|
begin |
1266 |
< |
Result := FFirebirdAPI <> nil; |
1266 |
> |
Result := FDefaultFBLibrary <> nil; |
1267 |
|
try |
1072 |
– |
{$IFDEF USEFIREBIRD3API} |
1073 |
– |
if not Result then |
1074 |
– |
begin |
1075 |
– |
FFirebirdAPI := TFB30ClientAPI.Create; |
1076 |
– |
Result := FFirebirdAPI.HasMasterIntf; |
1077 |
– |
end; |
1078 |
– |
{$ENDIF} |
1079 |
– |
{$IFDEF USELEGACYFIREBIRDAPI} |
1268 |
|
if not Result then |
1269 |
|
begin |
1270 |
< |
FFirebirdAPI := nil; |
1271 |
< |
FFirebirdAPI := TFB25ClientAPI.Create; |
1272 |
< |
Result := true; |
1273 |
< |
end; |
1086 |
< |
{$ENDIF} |
1087 |
< |
if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then |
1088 |
< |
begin |
1089 |
< |
Result := false; |
1090 |
< |
FFirebirdAPI := nil; |
1270 |
> |
fblib := TFBLibraryImpl.Create; |
1271 |
> |
if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then |
1272 |
> |
FDefaultFBLibrary := fblib; |
1273 |
> |
Result := FDefaultFBLibrary <> nil; |
1274 |
|
end; |
1275 |
|
except |
1276 |
|
SysUtils.showexception(ExceptObject,ExceptAddr); |
1284 |
|
IBError(ibxeInterBaseMissing, [nil]); |
1285 |
|
end; |
1286 |
|
|
1287 |
+ |
function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary; |
1288 |
+ |
var fblib: IFirebirdLibrary; |
1289 |
+ |
begin |
1290 |
+ |
if trim(aLibPathName) = '' then |
1291 |
+ |
begin |
1292 |
+ |
CheckIBLoaded; |
1293 |
+ |
Result := FDefaultFBLibrary; |
1294 |
+ |
end |
1295 |
+ |
else |
1296 |
+ |
begin |
1297 |
+ |
fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName); |
1298 |
+ |
if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then |
1299 |
+ |
IBError(ibxeInterBaseMissing, [nil]); |
1300 |
+ |
Result := fblib; |
1301 |
+ |
end; |
1302 |
+ |
end; |
1303 |
+ |
|
1304 |
|
{ EIBError } |
1305 |
|
|
1306 |
< |
constructor EIBError.Create(ASQLCode: Long; Msg: string); |
1306 |
> |
constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString); |
1307 |
|
begin |
1308 |
|
inherited Create(Msg); |
1309 |
|
FSQLCode := ASQLCode; |
1318 |
|
end; |
1319 |
|
|
1320 |
|
constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long; |
1321 |
< |
Msg: string); |
1321 |
> |
Msg: AnsiString); |
1322 |
|
begin |
1323 |
|
inherited Create(ASQLCode,Msg); |
1324 |
|
FIBErrorCode := AIBErrorCode; |
1331 |
|
end; |
1332 |
|
|
1333 |
|
initialization |
1334 |
< |
FFirebirdAPI := nil; |
1334 |
> |
FDefaultFBLibrary := nil; |
1335 |
|
|
1336 |
+ |
finalization |
1337 |
+ |
FDefaultFBLibrary := nil; |
1338 |
|
|
1339 |
|
end. |
1340 |
|
|