74 |
|
uses |
75 |
|
Classes, SysUtils, FBClientAPI, IBHeader, IBExternals, IB; |
76 |
|
|
77 |
– |
const |
78 |
– |
FBClientInterfaceVersion = '2.5'; |
79 |
– |
|
77 |
|
type |
78 |
|
|
79 |
|
{ TFB25Status } |
111 |
|
BLOB_put: TBLOB_put; |
112 |
|
isc_wait_for_event: Tisc_wait_for_event; |
113 |
|
isc_vax_integer: Tisc_vax_integer; |
117 |
– |
isc_portable_integer: Tisc_portable_integer; |
114 |
|
isc_blob_info: Tisc_blob_info; |
115 |
|
isc_blob_lookup_desc: Tisc_blob_lookup_desc; |
116 |
|
isc_open_blob2: Tisc_open_blob2; |
146 |
|
isc_detach_database: Tisc_detach_database; |
147 |
|
isc_attach_database: Tisc_attach_database; |
148 |
|
isc_database_info: Tisc_database_info; |
149 |
+ |
isc_transaction_info: Tisc_transaction_info; |
150 |
|
isc_start_transaction: Tisc_start_transaction; |
151 |
|
isc_start_multiple: Tisc_start_multiple; |
152 |
|
isc_commit_transaction: Tisc_commit_transaction; |
167 |
|
|
168 |
|
public |
169 |
|
{Helper Functions} |
173 |
– |
function DecodeInteger(bufptr: PByte; len: short): integer; override; |
170 |
|
procedure SQLEncodeDate(aDate: TDateTime; bufptr: PByte); override; |
171 |
|
function SQLDecodeDate(bufptr: PByte): TDateTime; override; |
172 |
|
procedure SQLEncodeTime(aTime: TDateTime; bufptr: PByte); override; |
186 |
|
{Start Transaction against multiple databases} |
187 |
|
function AllocateTPB: ITPB; |
188 |
|
function StartTransaction(Attachments: array of IAttachment; |
189 |
< |
TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; overload; |
189 |
> |
TPB: array of byte; DefaultCompletion: TTransactionCompletion; aName: AnsiString=''): ITransaction; overload; |
190 |
|
function StartTransaction(Attachments: array of IAttachment; |
191 |
< |
TPB: ITPB; DefaultCompletion: TTransactionCompletion): ITransaction; overload; |
191 |
> |
TPB: ITPB; DefaultCompletion: TTransactionCompletion; aName: AnsiString=''): ITransaction; overload; |
192 |
|
|
193 |
|
{Service Manager} |
194 |
|
function AllocateSPB: ISPB; |
214 |
|
uses FBMessages, |
215 |
|
{$IFDEF WINDOWS}Windows, {$ENDIF} |
216 |
|
{$IFDEF FPC} Dynlibs, {$ENDIF} |
217 |
< |
FB25Attachment, FB25Transaction, FB25Services, FBParamBlock, |
218 |
< |
IBUtils; |
217 |
> |
FB25Attachment, FB25Transaction, FB25Services, |
218 |
> |
IBUtils, FBAttachment, FBTransaction, FBServices; |
219 |
|
|
220 |
|
{ Stubs for 6.0 only functions } |
221 |
|
function isc_rollback_retaining_stub(status_vector : PISC_STATUS; |
343 |
|
BLOB_put := GetProcAddr('BLOB_put'); {do not localize} |
344 |
|
isc_wait_for_event := GetProcAddr('isc_wait_for_event'); {do not localize} |
345 |
|
isc_vax_integer := GetProcAddr('isc_vax_integer'); {do not localize} |
350 |
– |
isc_portable_integer := GetProcAddr('isc_portable_integer'); {do not localize} |
346 |
|
isc_blob_info := GetProcAddr('isc_blob_info'); {do not localize} |
347 |
|
isc_blob_lookup_desc := GetProcAddr('isc_blob_lookup_desc'); {do not localize} |
348 |
|
isc_open_blob2 := GetProcAddr('isc_open_blob2'); {do not localize} |
368 |
|
isc_detach_database := GetProcAddr('isc_detach_database'); {do not localize} |
369 |
|
isc_attach_database := GetProcAddr('isc_attach_database'); {do not localize} |
370 |
|
isc_database_info := GetProcAddr('isc_database_info'); {do not localize} |
371 |
+ |
isc_transaction_info := GetProcAddr('isc_transaction_info'); {do not localize} |
372 |
|
isc_start_transaction := GetProcAddr('isc_start_transaction'); {do not localize} |
373 |
|
isc_start_multiple := GetProcAddr('isc_start_multiple'); {do not localize} |
374 |
|
isc_commit_transaction := GetProcAddr('isc_commit_transaction'); {do not localize} |
505 |
|
end; |
506 |
|
|
507 |
|
function TFB25ClientAPI.StartTransaction(Attachments: array of IAttachment; |
508 |
< |
TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; |
508 |
> |
TPB: array of byte; DefaultCompletion: TTransactionCompletion; aName: AnsiString): ITransaction; |
509 |
|
begin |
510 |
< |
Result := TFB25Transaction.Create(self,Attachments,TPB,DefaultCompletion); |
510 |
> |
Result := TFB25Transaction.Create(self,Attachments,TPB,DefaultCompletion,aName); |
511 |
|
end; |
512 |
|
|
513 |
|
function TFB25ClientAPI.StartTransaction(Attachments: array of IAttachment; |
514 |
< |
TPB: ITPB; DefaultCompletion: TTransactionCompletion): ITransaction; |
514 |
> |
TPB: ITPB; DefaultCompletion: TTransactionCompletion; aName: AnsiString): ITransaction; |
515 |
|
begin |
516 |
< |
Result := TFB25Transaction.Create(self,Attachments,TPB,DefaultCompletion); |
516 |
> |
Result := TFB25Transaction.Create(self,Attachments,TPB,DefaultCompletion, aName); |
517 |
|
end; |
518 |
|
|
519 |
|
function TFB25ClientAPI.HasServiceAPI: boolean; |
557 |
|
Result := nil; |
558 |
|
end; |
559 |
|
|
564 |
– |
function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer; |
565 |
– |
begin |
566 |
– |
Result := isc_portable_integer(bufptr,len); |
567 |
– |
end; |
568 |
– |
|
560 |
|
procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte); |
561 |
|
var |
562 |
|
tm_date: TCTimeStructure; |
592 |
|
procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte); |
593 |
|
var |
594 |
|
tm_date: TCTimeStructure; |
595 |
< |
Hr, Mt, S, Ms: Word; |
595 |
> |
Hr, Mt, S: Word; |
596 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
597 |
|
begin |
598 |
< |
DecodeTime(aTime, Hr, Mt, S, Ms); |
598 |
> |
FBDecodeTime(aTime, Hr, Mt, S, DMs); |
599 |
|
with tm_date do begin |
600 |
|
tm_sec := S; |
601 |
|
tm_min := Mt; |
605 |
|
tm_year := 0; |
606 |
|
end; |
607 |
|
isc_encode_sql_time(@tm_date, PISC_TIME(bufptr)); |
608 |
< |
if Ms > 0 then |
609 |
< |
Inc(PISC_TIME(bufptr)^,Ms*10); |
608 |
> |
if DMs > 0 then |
609 |
> |
Inc(PISC_TIME(bufptr)^,DMs); |
610 |
|
end; |
611 |
|
|
612 |
|
function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime; |
613 |
|
var |
614 |
|
tm_date: TCTimeStructure; |
615 |
< |
msecs: Word; |
615 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
616 |
|
begin |
617 |
|
isc_decode_sql_time(PISC_TIME(bufptr), @tm_date); |
618 |
|
try |
619 |
< |
msecs := (PISC_TIME(bufptr)^ mod 10000) div 10; |
620 |
< |
result := EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
621 |
< |
Word(tm_date.tm_sec), msecs) |
619 |
> |
DMs := PISC_TIME(bufptr)^ mod 10000; |
620 |
> |
result := FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
621 |
> |
Word(tm_date.tm_sec), DMs) |
622 |
|
except |
623 |
|
on E: EConvertError do begin |
624 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
630 |
|
var |
631 |
|
tm_date: TCTimeStructure; |
632 |
|
Yr, Mn, Dy, Hr, Mt, S, Ms: Word; |
633 |
+ |
DMs: cardinal; |
634 |
|
begin |
635 |
|
DecodeDate(aDateTime, Yr, Mn, Dy); |
636 |
< |
DecodeTime(aDateTime, Hr, Mt, S, Ms); |
636 |
> |
FBDecodeTime(aDateTime, Hr, Mt, S, DMs); |
637 |
|
with tm_date do begin |
638 |
|
tm_sec := S; |
639 |
|
tm_min := Mt; |
643 |
|
tm_year := Yr - 1900; |
644 |
|
end; |
645 |
|
isc_encode_date(@tm_date, PISC_QUAD(bufptr)); |
646 |
< |
if Ms > 0 then |
647 |
< |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10); |
646 |
> |
if DMs > 0 then |
647 |
> |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,DMs); |
648 |
|
end; |
649 |
|
|
650 |
|
function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime; |
651 |
|
var |
652 |
|
tm_date: TCTimeStructure; |
653 |
< |
msecs: Word; |
653 |
> |
Dmsecs: Word; |
654 |
|
begin |
655 |
|
isc_decode_date(PISC_QUAD(bufptr), @tm_date); |
656 |
|
try |
657 |
|
result := EncodeDate(Word(tm_date.tm_year + 1900), Word(tm_date.tm_mon + 1), |
658 |
|
Word(tm_date.tm_mday)); |
659 |
< |
msecs := (PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000) div 10; |
659 |
> |
Dmsecs := PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000; |
660 |
|
if result >= 0 then |
661 |
< |
result := result + EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
662 |
< |
Word(tm_date.tm_sec), msecs) |
661 |
> |
result := result + FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
662 |
> |
Word(tm_date.tm_sec), Dmsecs) |
663 |
|
else |
664 |
< |
result := result - EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
665 |
< |
Word(tm_date.tm_sec), msecs) |
664 |
> |
result := result - FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
665 |
> |
Word(tm_date.tm_sec), Dmsecs) |
666 |
|
except |
667 |
|
on E: EConvertError do begin |
668 |
|
IBError(ibxeInvalidDataConversion, [nil]); |