--- ibx/trunk/fbintf/client/FBTransaction.pas 2021/02/25 11:27:14 314 +++ ibx/trunk/fbintf/client/FBTransaction.pas 2021/02/25 11:56:36 315 @@ -116,9 +116,63 @@ type property TransactionSeqNo: integer read FSeqNo; end; + {The transaction user interface is used to force an action on the end of the + transaction.} + + ITransactionUser = interface + ['{156fcdc9-a326-44b3-a82d-f23c6fb9f97c}'] + procedure TransactionEnding(aTransaction: ITransaction; Force: boolean); + end; + + { TTPBItem } + + TTPBItem = class(TParamBlockItem,ITPBItem) + public + function getParamTypeName: AnsiString; override; + end; + + { TTPB } + + TTPB = class (TCustomParamBlock, ITPB) + protected + function LookupItemType(ParamTypeName: AnsiString): byte; override; + public + constructor Create(api: TFBClientAPI); + function GetDPBParamTypeName(ParamType: byte): Ansistring; + end; + implementation -uses FBMessages, FBStatement; +uses FBMessages; + +const + isc_tpb_last_tpb_constant = isc_tpb_at_snapshot_number; + + TPBConstantNames: array[1..isc_tpb_last_tpb_constant] of string = ( + 'consistency', + 'concurrency', + 'shared', + 'protected', + 'exclusive', + 'wait', + 'nowait', + 'read', + 'write', + 'lock_read', + 'lock_write', + 'verb_time', + 'commit_time', + 'ignore_limbo', + 'read_committed', + 'autocommit', + 'rec_version', + 'no_rec_version', + 'restart_requests', + 'no_auto_undo', + 'lock_timeout', + 'read_consistency', + 'at_snapshot_number' + ); { TFBTransaction } @@ -193,15 +247,16 @@ end; procedure TFBTransaction.DoDefaultTransactionEnd(Force: boolean); var i: integer; - intf: TInterfacedObject; + intf: IUnknown; + user: ITransactionUser; begin if InTransaction then begin for i := 0 to InterfaceCount - 1 do begin intf := GetInterface(i); - if (intf <> nil) and (intf is TFBStatement) then - TFBStatement(intf).TransactionEnding(self,Force); + if (intf <> nil) and (intf.QueryInterface(ITransactionUser,user) = S_OK) then + user.TransactionEnding(self,Force); end; case FDefaultCompletion of taRollback: @@ -237,5 +292,46 @@ begin Start(DefaultCompletion); end; +{ TTPBItem } + +function TTPBItem.getParamTypeName: AnsiString; +begin + Result := TPBPrefix + TPBConstantNames[getParamType]; +end; + + +{TTPB} + +constructor TTPB.Create(api: TFBClientAPI); +begin + inherited Create(api); + FDataLength := 1; + FBuffer^ := isc_tpb_version3; +end; + +function TTPB.GetDPBParamTypeName(ParamType: byte): Ansistring; +begin + if ParamType <= isc_tpb_last_tpb_constant then + Result := TPBConstantNames[ParamType] + else + Result := ''; +end; + +function TTPB.LookupItemType(ParamTypeName: AnsiString): byte; +var i: byte; +begin + Result := 0; + ParamTypeName := LowerCase(ParamTypeName); + if (Pos(TPBPrefix, ParamTypeName) = 1) then + Delete(ParamTypeName, 1, Length(TPBPrefix)); + + for i := 1 to isc_tpb_last_tpb_constant do + if (ParamTypeName = TPBConstantNames[i]) then + begin + Result := i; + break; + end; +end; + end.