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 |
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, FmtBcd; |
133 |
|
|
134 |
|
const |
135 |
|
{Interface version information} |
136 |
|
FBIntf_Major = 1; |
137 |
< |
FBIntf_Minor = 0; |
138 |
< |
FBIntf_Release = 2; |
139 |
< |
FBIntf_Version = '1.0.2'; |
137 |
> |
FBIntf_Minor = 2; |
138 |
> |
FBIntf_Release = 0; |
139 |
> |
FBIntf_Version = '1.2.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.} |
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 |
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 |
236 |
|
SQLGetSegment, SQLPutSegment, |
237 |
|
SQLExecProcedure, SQLStartTransaction, |
238 |
|
SQLCommit, SQLRollback, |
239 |
< |
SQLSelectForUpdate, SQLSetGenerator); |
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 IParameterBlock interface provides the template for all parameter |
252 |
|
block interfaces} |
261 |
|
property Items[index: integer]: _IItem read getItems; default; |
262 |
|
end; |
263 |
|
|
264 |
+ |
IParameterBlockWithTypeNames<_IItem> = interface(IParameterBlock<_IItem>) |
265 |
+ |
function AddByTypeName(ParamTypeName: AnsiString): _IItem; |
266 |
+ |
function GetDPBParamTypeName(ParamType: byte): Ansistring; |
267 |
+ |
end; |
268 |
+ |
|
269 |
|
{IParameterBlockItem is not used on its own but instead provides a base type for |
270 |
|
different parameter block items } |
271 |
|
|
283 |
|
property AsInteger: integer read getAsInteger write SetAsInteger; |
284 |
|
end; |
285 |
|
|
286 |
+ |
IParameterBlockItemWithTypeName = interface(IParameterBlockItem) |
287 |
+ |
function getParamTypeName: AnsiString; |
288 |
+ |
end; |
289 |
|
|
290 |
|
{The IStatus interface provides access to error information, if any, returned |
291 |
|
by the last API call. It can also be used to customise the error message |
294 |
|
This interface can be accessed from IFirebirdAPI. |
295 |
|
} |
296 |
|
|
297 |
+ |
TIBDataBaseErrorMessage = (ShowSQLCode, |
298 |
+ |
ShowIBMessage, |
299 |
+ |
ShowSQLMessage); |
300 |
+ |
|
301 |
+ |
TIBDataBaseErrorMessages = set of TIBDataBaseErrorMessage; |
302 |
+ |
|
303 |
|
IStatus = interface |
304 |
|
['{34167722-af38-4831-b08a-93162d58ede3}'] |
305 |
|
function GetIBErrorCode: Long; |
326 |
|
function GetSQLTypeName: AnsiString; |
327 |
|
function GetScale: integer; |
328 |
|
function GetSize: cardinal; |
329 |
+ |
function GetCharSetWidth: integer; |
330 |
|
function GetCharSetID: cardinal; |
331 |
|
function GetTableName: AnsiString; |
332 |
|
function GetColumnName: AnsiString; |
365 |
|
function GetAsBoolean(index: array of integer): boolean; |
366 |
|
function GetAsCurrency(index: array of integer): Currency; |
367 |
|
function GetAsInt64(index: array of integer): Int64; |
368 |
< |
function GetAsDateTime(index: array of integer): TDateTime; |
368 |
> |
function GetAsDateTime(index: array of integer): TDateTime; overload; |
369 |
> |
procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload; |
370 |
> |
procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload; |
371 |
> |
procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload; |
372 |
> |
procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload; |
373 |
> |
function GetAsUTCDateTime(index: array of integer): TDateTime; |
374 |
|
function GetAsDouble(index: array of integer): Double; |
375 |
|
function GetAsFloat(index: array of integer): Float; |
376 |
|
function GetAsLong(index: array of integer): Long; |
377 |
|
function GetAsShort(index: array of integer): Short; |
378 |
|
function GetAsString(index: array of integer): AnsiString; |
379 |
|
function GetAsVariant(index: array of integer): Variant; |
380 |
+ |
function GetAsBCD(index: array of integer): tBCD; |
381 |
|
procedure SetAsInteger(index: array of integer; AValue: integer); |
382 |
|
procedure SetAsBoolean(index: array of integer; AValue: boolean); |
383 |
|
procedure SetAsCurrency(index: array of integer; Value: Currency); |
384 |
|
procedure SetAsInt64(index: array of integer; Value: Int64); |
385 |
|
procedure SetAsDate(index: array of integer; Value: TDateTime); |
386 |
+ |
procedure SetAsDateTime(index: array of integer; Value: TDateTime); overload; |
387 |
+ |
procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload; |
388 |
+ |
procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZone: AnsiString); overload; |
389 |
+ |
procedure SetAsTime(index: array of integer; Value: TDateTime); overload; |
390 |
+ |
procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload; |
391 |
+ |
procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload; |
392 |
+ |
procedure SetAsUTCDateTime(index: array of integer; aUTCTime: TDateTime); |
393 |
|
procedure SetAsLong(index: array of integer; Value: Long); |
321 |
– |
procedure SetAsTime(index: array of integer; Value: TDateTime); |
322 |
– |
procedure SetAsDateTime(index: array of integer; Value: TDateTime); |
394 |
|
procedure SetAsDouble(index: array of integer; Value: Double); |
395 |
|
procedure SetAsFloat(index: array of integer; Value: Float); |
396 |
|
procedure SetAsShort(index: array of integer; Value: Short); |
397 |
|
procedure SetAsString(index: array of integer; Value: AnsiString); |
398 |
|
procedure SetAsVariant(index: array of integer; Value: Variant); |
399 |
+ |
procedure SetAsBcd(index: array of integer; aValue: tBCD); |
400 |
|
procedure SetBounds(dim, UpperBound, LowerBound: integer); |
401 |
|
function GetAttachment: IAttachment; |
402 |
|
function GetTransaction: ITransaction; |
424 |
|
['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}'] |
425 |
|
end; |
426 |
|
|
427 |
< |
IBPB = interface(IParameterBlock<IBPBItem>) |
427 |
> |
IBPB = interface (IParameterBlock<IBPBItem>) |
428 |
|
['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}'] |
429 |
|
end; |
430 |
|
|
467 |
|
the output of an SQL Statement. |
468 |
|
} |
469 |
|
|
470 |
+ |
TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP} |
471 |
+ |
dfDateTime, {SQL DATETIME} |
472 |
+ |
dfTime, {SQL TIME} |
473 |
+ |
dfTimestampTZ, {SQL_TIMESTAMP_TZ} |
474 |
+ |
dfTimeTZ); {SQLTIME_TZ |
475 |
+ |
|
476 |
|
{ IColumnMetaData } |
477 |
|
|
478 |
|
IColumnMetaData = interface |
489 |
|
function getScale: integer; |
490 |
|
function getCharSetID: cardinal; |
491 |
|
function getCodePage: TSystemCodePage; |
492 |
+ |
function GetCharSetWidth: integer; |
493 |
|
function getIsNullable: boolean; |
494 |
|
function GetSize: cardinal; |
495 |
|
function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type} |
496 |
|
function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type} |
497 |
+ |
function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer; |
498 |
+ |
function GetStatement: IStatement; |
499 |
+ |
function GetTransaction: ITransaction; |
500 |
|
property Name: AnsiString read GetName; |
501 |
|
property Size: cardinal read GetSize; |
502 |
|
property SQLType: cardinal read GetSQLType; |
538 |
|
|
539 |
|
ISQLData = interface(IColumnMetaData) |
540 |
|
['{3f493e31-7e3f-4606-a07c-b210b9e3619d}'] |
541 |
+ |
function GetStrDataLength: short; |
542 |
|
function GetAsBoolean: boolean; |
543 |
|
function GetAsCurrency: Currency; |
544 |
|
function GetAsInt64: Int64; |
545 |
< |
function GetAsDateTime: TDateTime; |
545 |
> |
function GetAsDateTime: TDateTime; overload; |
546 |
> |
procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload; |
547 |
> |
procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload; |
548 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload; |
549 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload; |
550 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload; |
551 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload; |
552 |
> |
function GetAsUTCDateTime: TDateTime; |
553 |
|
function GetAsDouble: Double; |
554 |
|
function GetAsFloat: Float; |
555 |
|
function GetAsLong: Long; |
562 |
|
function GetAsBlob: IBlob; overload; |
563 |
|
function GetAsBlob(BPB: IBPB): IBlob; overload; |
564 |
|
function GetAsArray: IArray; |
565 |
+ |
function GetAsBCD: tBCD; |
566 |
|
property AsDate: TDateTime read GetAsDateTime; |
567 |
|
property AsBoolean:boolean read GetAsBoolean; |
568 |
|
property AsTime: TDateTime read GetAsDateTime; |
580 |
|
property AsVariant: Variant read GetAsVariant ; |
581 |
|
property AsBlob: IBlob read GetAsBlob; |
582 |
|
property AsArray: IArray read GetAsArray; |
583 |
+ |
property AsBCD: tBCD read GetAsBCD; |
584 |
|
property IsNull: Boolean read GetIsNull; |
585 |
|
property Value: Variant read GetAsVariant; |
586 |
|
end; |
594 |
|
IResults = interface |
595 |
|
['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}'] |
596 |
|
function getCount: integer; |
597 |
+ |
function GetStatement: IStatement; |
598 |
|
function GetTransaction: ITransaction; |
599 |
|
function ByName(Idx: AnsiString): ISQLData; |
600 |
|
function getSQLData(index: integer): ISQLData; |
647 |
|
function GetAsBoolean: boolean; |
648 |
|
function GetAsCurrency: Currency; |
649 |
|
function GetAsInt64: Int64; |
650 |
< |
function GetAsDateTime: TDateTime; |
650 |
> |
function GetAsDateTime: TDateTime; overload; |
651 |
> |
procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload; |
652 |
> |
procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload; |
653 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload; |
654 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload; |
655 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload; |
656 |
> |
procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload; |
657 |
> |
function GetAsUTCDateTime: TDateTime; |
658 |
|
function GetAsDouble: Double; |
659 |
|
function GetAsFloat: Float; |
660 |
|
function GetAsLong: Long; |
666 |
|
function GetAsVariant: Variant; |
667 |
|
function GetAsBlob: IBlob; |
668 |
|
function GetAsArray: IArray; |
669 |
+ |
function GetAsBCD: tBCD; |
670 |
+ |
function GetStatement: IStatement; |
671 |
+ |
function GetTransaction: ITransaction; |
672 |
|
procedure Clear; |
673 |
|
function GetModified: boolean; |
674 |
|
procedure SetAsBoolean(AValue: boolean); |
676 |
|
procedure SetAsInt64(aValue: Int64); |
677 |
|
procedure SetAsDate(aValue: TDateTime); |
678 |
|
procedure SetAsLong(aValue: Long); |
679 |
< |
procedure SetAsTime(aValue: TDateTime); |
680 |
< |
procedure SetAsDateTime(aValue: TDateTime); |
679 |
> |
procedure SetAsTime(aValue: TDateTime); overload; |
680 |
> |
procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload; |
681 |
> |
procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload; |
682 |
> |
procedure SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload; |
683 |
> |
procedure SetAsTime(aValue: TDateTime; aTimeZone: AnsiString); overload; |
684 |
> |
procedure SetAsDateTime(aValue: TDateTime); overload; |
685 |
> |
procedure SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload; |
686 |
> |
procedure SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString); overload; |
687 |
> |
procedure SetAsUTCDateTime(aUTCTime: TDateTime); |
688 |
|
procedure SetAsDouble(aValue: Double); |
689 |
|
procedure SetAsFloat(aValue: Float); |
690 |
|
procedure SetAsPointer(aValue: Pointer); |
696 |
|
procedure SetAsArray(anArray: IArray); |
697 |
|
procedure SetAsQuad(aValue: TISC_QUAD); |
698 |
|
procedure SetCharSetID(aValue: cardinal); |
699 |
+ |
procedure SetAsBcd(aValue: tBCD); |
700 |
|
property AsDate: TDateTime read GetAsDateTime write SetAsDate; |
701 |
|
property AsBoolean:boolean read GetAsBoolean write SetAsBoolean; |
702 |
|
property AsTime: TDateTime read GetAsDateTime write SetAsTime; |
713 |
|
property AsVariant: Variant read GetAsVariant write SetAsVariant; |
714 |
|
property AsBlob: IBlob read GetAsBlob write SetAsBlob; |
715 |
|
property AsArray: IArray read GetAsArray write SetAsArray; |
716 |
+ |
property AsBCD: tBCD read GetAsBCD write SetAsBCD; |
717 |
|
property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad; |
718 |
|
property Value: Variant read GetAsVariant write SetAsVariant; |
719 |
|
property IsNull: Boolean read GetIsNull write SetIsNull; |
734 |
|
function getSQLParam(index: integer): ISQLParam; |
735 |
|
function ByName(Idx: AnsiString): ISQLParam ; |
736 |
|
function GetModified: Boolean; |
737 |
+ |
function GetHasCaseSensitiveParams: Boolean; |
738 |
|
property Modified: Boolean read GetModified; |
739 |
|
property Params[index: integer]: ISQLParam read getSQLParam; default; |
740 |
|
property Count: integer read getCount; |
745 |
|
psRealTime, psUserTime, psBuffers, |
746 |
|
psReads, psWrites, psFetches,psDeltaMemory); |
747 |
|
|
748 |
< |
TPerfCounters = array[TPerfStats] of comp; |
748 |
> |
TPerfCounters = array[TPerfStats] of Int64; |
749 |
|
|
750 |
|
{The IStatement interface provides access to an SQL Statement once it has been |
751 |
|
initially prepared. The interface is returned from the IAttachment interface. |
759 |
|
function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean; |
760 |
|
function GetSQLStatementType: TIBSQLStatementTypes; |
761 |
|
function GetSQLText: AnsiString; |
762 |
+ |
function GetProcessedSQLText: AnsiString; |
763 |
|
function GetSQLDialect: integer; |
764 |
|
function IsPrepared: boolean; |
765 |
|
procedure Prepare(aTransaction: ITransaction=nil); |
786 |
|
found in the Interbase 6.0 API Guide. |
787 |
|
} |
788 |
|
|
789 |
< |
ITPBItem = interface(IParameterBlockItem) |
789 |
> |
ITPBItem = interface(IParameterBlockItemWithTypeName) |
790 |
|
['{544c1f2b-7c12-4a87-a4a5-face7ea72671}'] |
791 |
+ |
function getParamTypeName: AnsiString; |
792 |
|
end; |
793 |
|
|
794 |
< |
ITPB = interface(IParameterBlock<ITPBItem>) |
794 |
> |
ITPB = interface(IParameterBlockWithTypeNames<ITPBItem>) |
795 |
|
['{7369b0ff-defe-437b-81fe-19b211d42d25}'] |
796 |
|
end; |
797 |
|
|
857 |
|
function GetAttachment: IAttachment; |
858 |
|
end; |
859 |
|
|
860 |
+ |
TTZTextOptions = (tzOffset, {Time Zone Rendered as an offset to GMT} |
861 |
+ |
tzGMT, {No Time Zone. Time part is always rendered in GMT} |
862 |
+ |
tzOriginalID); {Time Zone shown as originally entered} |
863 |
+ |
|
864 |
+ |
{The ITimeZoneServices interface provides access to the time zone database |
865 |
+ |
used for the attachment. It may be used in support of TIMESTAMP WITH TIME ZONE |
866 |
+ |
and TIME WITH TIME ZONE data types.} |
867 |
+ |
|
868 |
+ |
ITimeZoneServices = interface |
869 |
+ |
['{163821f5-ebef-42b9-ac60-8ac4b5c09954}'] |
870 |
+ |
{utility functions} |
871 |
+ |
function TimeZoneID2TimeZoneName(aTimeZoneID: TFBTimeZoneID): AnsiString; |
872 |
+ |
function TimeZoneName2TimeZoneID(aTimeZone: AnsiString): TFBTimeZoneID; |
873 |
+ |
function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload; |
874 |
+ |
function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload; |
875 |
+ |
function GMTToLocalTime(aGMTTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload; |
876 |
+ |
function GMTToLocalTime(aGMTTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload; |
877 |
+ |
function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZone: AnsiString): integer; overload; |
878 |
+ |
function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): integer; overload; |
879 |
+ |
|
880 |
+ |
{Time Zone DB Information} |
881 |
+ |
function UsingRemoteTZDB: boolean; |
882 |
+ |
procedure SetUseLocalTZDB(useLocalTZDB: boolean); |
883 |
+ |
function GetLocalTimeZoneName: AnsiString; |
884 |
+ |
function GetLocalTimeZoneID: TFBTimeZoneID; |
885 |
+ |
procedure GetTimeZoneInfo(aTimeZone: AnsiString; OnDate: TDateTime; |
886 |
+ |
var ZoneOffset, DSTOffset, EffectiveOffset: integer); |
887 |
+ |
{Configurable Options} |
888 |
+ |
function GetTimeTZDate: TDateTime; |
889 |
+ |
procedure SetTimeTZDate(aDate: TDateTime); |
890 |
+ |
function GetTZTextOption: TTZTextOptions; |
891 |
+ |
procedure SetTZTextOption(aOptionValue: TTZTextOptions); |
892 |
+ |
end; |
893 |
+ |
|
894 |
|
{The IDBInformation Interface. |
895 |
|
|
896 |
|
An IDBInformation interface is returned by the IAttachment GetDBInformation |
922 |
|
function getAsInteger: integer; |
923 |
|
procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString); |
924 |
|
function getAsBytes: TByteArray; |
925 |
+ |
function getAsDateTime: TDateTime; |
926 |
|
procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString); |
927 |
|
function getOperationCounts: TDBOperationCounts; |
928 |
|
procedure DecodeUserNames(UserNames: TStrings); |
949 |
|
property Items[index: integer]: IDBInfoItem read getItem; default; |
950 |
|
end; |
951 |
|
|
952 |
+ |
{The Database Information Request Block is used to pass requests for |
953 |
+ |
database information where at least one item requested has a parameter. |
954 |
+ |
At present, this is only fb_info_page_contents which has a single |
955 |
+ |
integer parameter.} |
956 |
+ |
|
957 |
+ |
IDIRBItem = interface(IParameterBlockItem) |
958 |
+ |
['{d34a7511-8435-4a24-81a7-5103d218d234}'] |
959 |
+ |
end; |
960 |
+ |
|
961 |
+ |
IDIRB = interface(IParameterBlock<IDIRBItem>) |
962 |
+ |
['{1010e5ac-0a8f-403b-a302-91625e9d9579}'] |
963 |
+ |
end; |
964 |
+ |
|
965 |
+ |
|
966 |
|
{The Database Parameter Block (DPB). |
967 |
|
|
968 |
|
The DPB provides the parameters used when connecting to a database. It is allocated |
974 |
|
found in the Interbase 6.0 API Guide. |
975 |
|
} |
976 |
|
|
977 |
< |
IDPBItem = interface(IParameterBlockItem) |
977 |
> |
IDPBItem = interface(IParameterBlockItemWithTypeName) |
978 |
|
['{123d4ad0-087a-4cd1-a344-1b3d03b30673}'] |
979 |
|
end; |
980 |
|
|
981 |
< |
IDPB = interface(IParameterBlock<IDPBItem>) |
982 |
< |
['{e676067b-1cf4-4eba-9256-9724f57e0d16}'] |
983 |
< |
end; |
981 |
> |
IDPB = interface(IParameterBlockWithTypeNames<IDPBItem>) |
982 |
> |
['{e676067b-1cf4-4eba-9256-9724f57e0d16}'] |
983 |
> |
end; |
984 |
|
|
985 |
|
{The IAttachment interface provides access to a Database Connection. It may be |
986 |
|
used to: |
1011 |
|
|
1012 |
|
IAttachment = interface |
1013 |
|
['{466e9b67-9def-4807-b3e7-e08a35e7185c}'] |
1014 |
+ |
function getFirebirdAPI: IFirebirdAPI; |
1015 |
|
function getDPB: IDPB; |
1016 |
|
function AllocateBPB: IBPB; |
1017 |
+ |
function AllocateDIRB: IDIRB; |
1018 |
|
procedure Connect; |
1019 |
|
procedure Disconnect(Force: boolean=false); |
1020 |
|
function IsConnected: boolean; |
1047 |
|
function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload; |
1048 |
|
function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload; |
1049 |
|
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
1050 |
< |
aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload; |
1050 |
> |
aSQLDialect: integer; GenerateParamNames: boolean=false; |
1051 |
> |
CaseSensitiveParams: boolean = false): IStatement; overload; |
1052 |
|
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
1053 |
< |
GenerateParamNames: boolean=false): IStatement; overload; |
1053 |
> |
GenerateParamNames: boolean=false; |
1054 |
> |
CaseSensitiveParams: boolean = false): IStatement; overload; |
1055 |
|
|
1056 |
|
{Events} |
1057 |
|
function GetEventHandler(Events: TStrings): IEvents; overload; |
1062 |
|
function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload; |
1063 |
|
function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload; |
1064 |
|
function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload; |
1065 |
< |
function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; |
1065 |
> |
function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload; |
1066 |
> |
function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload; |
1067 |
|
|
1068 |
|
{Array - may use to open existing arrays. However, ISQLData.AsArray is preferred} |
1069 |
|
|
1070 |
< |
function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; |
1070 |
> |
function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload; |
1071 |
> |
function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload; |
1072 |
|
function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload; |
1073 |
|
function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload; |
1074 |
|
function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString; |
1081 |
|
function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData; |
1082 |
|
function GetDBInformation(Requests: array of byte): IDBInformation; overload; |
1083 |
|
function GetDBInformation(Request: byte): IDBInformation; overload; |
1084 |
+ |
function GetDBInformation(Requests: IDIRB): IDBInformation; overload; |
1085 |
+ |
function GetConnectString: AnsiString; |
1086 |
+ |
function GetRemoteProtocol: AnsiString; |
1087 |
+ |
function GetAuthenticationMethod: AnsiString; |
1088 |
+ |
function GetSecurityDatabase: AnsiString; |
1089 |
+ |
function GetODSMajorVersion: integer; |
1090 |
+ |
function GetODSMinorVersion: integer; |
1091 |
+ |
procedure getFBVersion(version: TStrings); |
1092 |
|
function HasActivity: boolean; |
1093 |
< |
end; |
1093 |
> |
function HasDecFloatSupport: boolean; |
1094 |
|
|
1095 |
< |
TProtocol = (TCP, SPX, NamedPipe, Local); |
1095 |
> |
{Character Sets} |
1096 |
> |
function HasDefaultCharSet: boolean; |
1097 |
> |
function GetDefaultCharSetID: integer; |
1098 |
> |
function GetCharsetName(CharSetID: integer): AnsiString; |
1099 |
> |
function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean; |
1100 |
> |
function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean; |
1101 |
> |
function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean; |
1102 |
> |
function CharSetWidth(CharSetID: integer; var Width: integer): boolean; |
1103 |
> |
procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage; |
1104 |
> |
AllowReverseLookup:boolean; out CharSetID: integer); |
1105 |
> |
|
1106 |
> |
{Time Zone Database} |
1107 |
> |
function GetTimeZoneServices: ITimeZoneServices; |
1108 |
> |
function HasTimeZoneSupport: boolean; |
1109 |
> |
end; |
1110 |
> |
|
1111 |
> |
TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol); |
1112 |
> |
TProtocol = TCP..xnet; |
1113 |
|
|
1114 |
|
{Service Parameter Block (SPB). |
1115 |
|
|
1123 |
|
|
1124 |
|
} |
1125 |
|
|
1126 |
< |
ISPBItem = interface(IParameterBlockItem) |
1126 |
> |
ISPBItem = interface(IParameterBlockItemWithTypeName) |
1127 |
|
['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}'] |
1128 |
|
end; |
1129 |
|
|
1130 |
< |
ISPB = interface(IParameterBlock<ISPBItem>) |
1130 |
> |
ISPB = interface(IParameterBlockWithTypeNames<ISPBItem>) |
1131 |
|
['{2c5836fd-41ed-4426-9b7d-5af580ec2659}'] |
1132 |
|
end; |
1133 |
|
|
1214 |
|
property Count: integer read getCount; |
1215 |
|
end; |
1216 |
|
|
1217 |
+ |
IFirebirdLibrary = interface; |
1218 |
+ |
|
1219 |
|
{The IServiceManager interface provides access to a service manager. It can |
1220 |
|
used to Detach and re-attach to Service Manager, to start services and to |
1221 |
|
query the service manager. |
1227 |
|
|
1228 |
|
IServiceManager = interface |
1229 |
|
['{905b587d-1e1f-4e40-a3f8-a3519f852e48}'] |
1230 |
+ |
function getFirebirdAPI: IFirebirdAPI; |
1231 |
|
function getSPB: ISPB; |
1232 |
|
function getServerName: AnsiString; |
1233 |
+ |
function getProtocol: TProtocol; |
1234 |
+ |
function getPortNo: AnsiString; |
1235 |
|
procedure Attach; |
1236 |
|
procedure Detach(Force: boolean=false); |
1237 |
|
function IsAttached: boolean; |
1238 |
|
function AllocateSRB: ISRB; |
1239 |
|
function AllocateSQPB: ISQPB; |
1240 |
< |
procedure Start(Request: ISRB); |
1241 |
< |
function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload; |
1242 |
< |
function Query(Request: ISRB) :IServiceQueryResults; overload; |
1240 |
> |
function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean; |
1241 |
> |
function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload; |
1242 |
> |
function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload; |
1243 |
> |
end; |
1244 |
> |
|
1245 |
> |
{Tbe Firebird Library API used to get information about the Firebird library} |
1246 |
> |
|
1247 |
> |
|
1248 |
> |
IFirebirdLibrary = interface |
1249 |
> |
['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}'] |
1250 |
> |
function GetHandle: TLibHandle; |
1251 |
> |
function GetLibraryName: string; |
1252 |
> |
function GetLibraryFilePath: string; |
1253 |
> |
function GetFirebirdAPI: IFirebirdAPI; |
1254 |
|
end; |
1255 |
|
|
1256 |
|
{The Firebird API. |
1261 |
|
The interface is returned by the FirebirdAPI function. |
1262 |
|
} |
1263 |
|
|
1264 |
+ |
{ IFirebirdAPI } |
1265 |
+ |
|
1266 |
|
IFirebirdAPI = interface |
1267 |
|
['{edeee691-c8d3-4dcf-a780-cd7e432821d5}'] |
1268 |
|
{Database connections} |
1281 |
|
{Service Manager} |
1282 |
|
function HasServiceAPI: boolean; |
1283 |
|
function AllocateSPB: ISPB; |
1284 |
< |
function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; |
1284 |
> |
function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload; |
1285 |
> |
function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload; |
1286 |
|
|
1287 |
|
{Information} |
1288 |
|
function GetStatus: IStatus; |
1075 |
– |
function GetLibraryName: string; |
1289 |
|
function HasRollbackRetaining: boolean; |
1290 |
|
function IsEmbeddedServer: boolean; |
1291 |
|
function GetImplementationVersion: AnsiString; |
1292 |
+ |
function GetClientMajor: integer; |
1293 |
+ |
function GetClientMinor: integer; |
1294 |
+ |
function HasDecFloatSupport: boolean; |
1295 |
+ |
function HasLocalTZDB: boolean; |
1296 |
+ |
function HasTimeZoneSupport: boolean; |
1297 |
+ |
function HasExtendedTZSupport: boolean; |
1298 |
|
|
1299 |
|
{Firebird 3 API} |
1300 |
|
function HasMasterIntf: boolean; |
1301 |
< |
function GetIMaster: TObject; |
1302 |
< |
|
1084 |
< |
{utility} |
1085 |
< |
function GetCharsetName(CharSetID: integer): AnsiString; |
1086 |
< |
function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean; |
1087 |
< |
function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean; |
1088 |
< |
function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean; |
1089 |
< |
function CharSetWidth(CharSetID: integer; var Width: integer): boolean; |
1301 |
> |
function GetIMaster: TObject; deprecated 'Use FirebirdAPI.QueryInterface and FBClientLib.pas IFBIMasterProvider instead'; |
1302 |
> |
function GetFBLibrary: IFirebirdLibrary; |
1303 |
|
end; |
1304 |
|
|
1305 |
|
type |
1334 |
|
{IB Client Exceptions} |
1335 |
|
EIBClientError = class(EIBError); |
1336 |
|
|
1124 |
– |
{IBError is used internally and by IBX to throw an EIBClientError} |
1125 |
– |
|
1126 |
– |
procedure IBError(ErrMess: TIBClientError; const Args: array of const); |
1127 |
– |
|
1337 |
|
{The Firebird API function is used to access the IFirebirdAPI interface. |
1338 |
|
|
1339 |
|
It will load the Firebird Client Library if this is not already loaded and |
1343 |
|
function FirebirdAPI: IFirebirdAPI; |
1344 |
|
|
1345 |
|
{IBX support functions. Probably best ignored i.e. always used the FirebirdAPI |
1346 |
< |
functino to load the library and check if it's loaded.} |
1346 |
> |
function to load the library and check if it's loaded.} |
1347 |
|
|
1348 |
|
function TryIBLoad: Boolean; |
1349 |
|
procedure CheckIBLoaded; |
1350 |
|
|
1351 |
+ |
{If you want to explicitly load the Firebird library from a |
1352 |
+ |
non-default location then use this function and its GetFirebirdAPI function |
1353 |
+ |
to get the API.} |
1354 |
+ |
|
1355 |
+ |
function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary; |
1356 |
+ |
|
1357 |
+ |
|
1358 |
|
implementation |
1359 |
|
|
1360 |
|
uses FBClientAPI |
1361 |
|
{$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF} |
1362 |
|
{$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF}; |
1363 |
|
|
1364 |
< |
var FFirebirdAPI: IFirebirdAPI; |
1364 |
> |
var FDefaultFBLibrary: IFirebirdLibrary; |
1365 |
> |
|
1366 |
> |
type |
1367 |
> |
|
1368 |
> |
{ TFBLibrary } |
1369 |
> |
|
1370 |
> |
TFBLibraryImpl = class(TFBLibrary) |
1371 |
> |
protected |
1372 |
> |
function GetFirebird3API: IFirebirdAPI; override; |
1373 |
> |
function GetLegacyFirebirdAPI: IFirebirdAPI; override; |
1374 |
> |
end; |
1375 |
> |
|
1376 |
> |
function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI; |
1377 |
> |
begin |
1378 |
> |
{$IFDEF USEFIREBIRD3API} |
1379 |
> |
Result := TFB30ClientAPI.Create(self); |
1380 |
> |
{$ELSE} |
1381 |
> |
Result := nil; |
1382 |
> |
{$ENDIF} |
1383 |
> |
end; |
1384 |
> |
|
1385 |
> |
function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI; |
1386 |
> |
begin |
1387 |
> |
{$IFDEF USELEGACYFIREBIRDAPI} |
1388 |
> |
Result := TFB25ClientAPI.Create(self); |
1389 |
> |
{$ELSE} |
1390 |
> |
Result := nil; |
1391 |
> |
{$ENDIF} |
1392 |
> |
end; |
1393 |
|
|
1394 |
|
function FirebirdAPI: IFirebirdAPI; |
1395 |
|
begin |
1396 |
< |
if FFirebirdAPI = nil then |
1396 |
> |
if FDefaultFBLibrary = nil then |
1397 |
|
CheckIBLoaded; |
1398 |
< |
Result := FFirebirdAPI; |
1398 |
> |
Result := FDefaultFBLibrary.GetFirebirdAPI; |
1399 |
|
end; |
1400 |
|
|
1401 |
|
function TryIBLoad: Boolean; |
1402 |
+ |
var fblib: IFirebirdLibrary; |
1403 |
|
begin |
1404 |
< |
Result := FFirebirdAPI <> nil; |
1404 |
> |
Result := FDefaultFBLibrary <> nil; |
1405 |
|
try |
1161 |
– |
{$IFDEF USEFIREBIRD3API} |
1406 |
|
if not Result then |
1407 |
|
begin |
1408 |
< |
FFirebirdAPI := TFB30ClientAPI.Create; |
1409 |
< |
Result := FFirebirdAPI.HasMasterIntf; |
1410 |
< |
end; |
1411 |
< |
{$ENDIF} |
1168 |
< |
{$IFDEF USELEGACYFIREBIRDAPI} |
1169 |
< |
if not Result then |
1170 |
< |
begin |
1171 |
< |
FFirebirdAPI := nil; |
1172 |
< |
FFirebirdAPI := TFB25ClientAPI.Create; |
1173 |
< |
Result := true; |
1174 |
< |
end; |
1175 |
< |
{$ENDIF} |
1176 |
< |
if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then |
1177 |
< |
begin |
1178 |
< |
Result := false; |
1179 |
< |
FFirebirdAPI := nil; |
1408 |
> |
fblib := TFBLibraryImpl.Create; |
1409 |
> |
if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then |
1410 |
> |
FDefaultFBLibrary := fblib; |
1411 |
> |
Result := FDefaultFBLibrary <> nil; |
1412 |
|
end; |
1413 |
|
except |
1414 |
|
SysUtils.showexception(ExceptObject,ExceptAddr); |
1422 |
|
IBError(ibxeInterBaseMissing, [nil]); |
1423 |
|
end; |
1424 |
|
|
1425 |
+ |
function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary; |
1426 |
+ |
var fblib: IFirebirdLibrary; |
1427 |
+ |
begin |
1428 |
+ |
if trim(aLibPathName) = '' then |
1429 |
+ |
begin |
1430 |
+ |
CheckIBLoaded; |
1431 |
+ |
Result := FDefaultFBLibrary; |
1432 |
+ |
end |
1433 |
+ |
else |
1434 |
+ |
begin |
1435 |
+ |
fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName); |
1436 |
+ |
if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then |
1437 |
+ |
IBError(ibxeInterBaseMissing, [nil]); |
1438 |
+ |
Result := fblib; |
1439 |
+ |
end; |
1440 |
+ |
end; |
1441 |
+ |
|
1442 |
|
{ EIBError } |
1443 |
|
|
1444 |
|
constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString); |
1462 |
|
FIBErrorCode := AIBErrorCode; |
1463 |
|
end; |
1464 |
|
|
1216 |
– |
procedure IBError(ErrMess: TIBClientError; const Args: array of const); |
1217 |
– |
begin |
1218 |
– |
raise EIBClientError.Create(Ord(ErrMess), |
1219 |
– |
Format(GetErrorMessage(ErrMess), Args)); |
1220 |
– |
end; |
1465 |
|
|
1466 |
|
initialization |
1467 |
< |
FFirebirdAPI := nil; |
1467 |
> |
FDefaultFBLibrary := nil; |
1468 |
|
|
1469 |
+ |
finalization |
1470 |
+ |
FDefaultFBLibrary := nil; |
1471 |
|
|
1472 |
|
end. |
1473 |
|
|