--- ibx/trunk/fbintf/client/FBStatement.pas 2021/02/25 11:56:36 315 +++ ibx/trunk/fbintf/client/FBStatement.pas 2021/08/23 14:22:29 345 @@ -44,6 +44,9 @@ uses Classes, SysUtils, IB, FBClientAPI, FBSQLData, FBOutputBlock, FBActivityMonitor, FBTransaction; +const + DefaultBatchRowLimit = 1000; + type TPerfStatistics = array[psCurrentMemory..psFetches] of Int64; @@ -74,11 +77,13 @@ type FBeforeStats: TPerfStatistics; FAfterStats: TPerfStatistics; FCaseSensitiveParams: boolean; + FBatchRowLimit: integer; + procedure CheckChangeBatchRowLimit; virtual; procedure CheckHandle; virtual; abstract; procedure CheckTransaction(aTransaction: ITransaction); procedure GetDsqlInfo(info_request: byte; buffer: ISQLInfoResults); overload; virtual; abstract; procedure InternalPrepare; virtual; abstract; - function InternalExecute(aTransaction: ITransaction): IResults; virtual; abstract; + function InternalExecute(Transaction: ITransaction): IResults; virtual; abstract; function InternalOpenCursor(aTransaction: ITransaction): IResultSet; virtual; abstract; procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); virtual; abstract; procedure FreeHandle; virtual; abstract; @@ -102,6 +107,7 @@ type function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean; function GetSQLStatementType: TIBSQLStatementTypes; + function GetSQLStatementTypeName: AnsiString; function GetSQLText: AnsiString; function GetProcessedSQLText: AnsiString; function GetSQLDialect: integer; @@ -122,6 +128,17 @@ type procedure SetRetainInterfaces(aValue: boolean); virtual; procedure EnableStatistics(aValue: boolean); function GetPerfStatistics(var stats: TPerfCounters): boolean; + function IsInBatchMode: boolean; virtual; + function HasBatchMode: boolean; virtual; + public + {IBatch support} + procedure AddToBatch; virtual; + function ExecuteBatch(aTransaction: ITransaction): IBatchCompletion; virtual; + procedure CancelBatch; virtual; + function GetBatchCompletion: IBatchCompletion; virtual; + function GetBatchRowLimit: integer; + procedure SetBatchRowLimit(aLimit: integer); + public property ChangeSeqNo: integer read FChangeSeqNo; property SQLParams: ISQLParams read GetSQLParams; property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType; @@ -133,6 +150,11 @@ uses FBMessages; { TFBStatement } +procedure TFBStatement.CheckChangeBatchRowLimit; +begin + //Do Nothing +end; + procedure TFBStatement.CheckTransaction(aTransaction: ITransaction); begin if (aTransaction = nil) then @@ -156,6 +178,7 @@ begin FFirebirdClientAPI := Attachment.getFirebirdAPI as TFBClientAPI; FSQLDialect := SQLDialect; FSQL := sql; + FBatchRowLimit := DefaultBatchRowLimit; end; constructor TFBStatement.CreateWithParameterNames(Attachment: IAttachment; @@ -231,6 +254,27 @@ begin Result := FSQLStatementType; end; +function TFBStatement.GetSQLStatementTypeName: AnsiString; +begin + case FSQLStatementType of + SQLUnknown: Result := 'SQL_Unknown'; + SQLSelect: Result := 'SQL_Select'; + SQLInsert: Result := 'SQL_Insert'; + SQLUpdate: Result := 'SQL_Update'; + SQLDelete: Result := 'SQL_Delete'; + SQLDDL: Result := 'SQL_DDL'; + SQLGetSegment: Result := 'SQL_GetSegment'; + SQLPutSegment: Result := 'SQL_PutSegment'; + SQLExecProcedure: Result := 'SQL_ExecProcedure'; + SQLStartTransaction: Result := 'SQL_StartTransaction'; + SQLCommit: Result := 'SQL_Commit'; + SQLRollback: Result := 'SQL_Rollback'; + SQLSelectForUpdate: Result := 'SQL_SelectForUpdate'; + SQLSetGenerator: Result := 'SQL_SetGenerator'; + SQLSavePoint: Result := 'SQL_SavePoint'; + end; +end; + function TFBStatement.GetSQLText: AnsiString; begin Result := FSQL; @@ -268,6 +312,38 @@ begin Result := InternalExecute(aTransaction); end; +procedure TFBStatement.AddToBatch; +begin + IBError(ibxeBatchModeNotSupported,[]); +end; + +function TFBStatement.ExecuteBatch(aTransaction: ITransaction + ): IBatchCompletion; +begin + IBError(ibxeBatchModeNotSupported,[]); +end; + +procedure TFBStatement.CancelBatch; +begin + IBError(ibxeBatchModeNotSupported,[]); +end; + +function TFBStatement.GetBatchCompletion: IBatchCompletion; +begin + IBError(ibxeBatchModeNotSupported,[]); +end; + +function TFBStatement.GetBatchRowLimit: integer; +begin + Result := FBatchRowLimit; +end; + +procedure TFBStatement.SetBatchRowLimit(aLimit: integer); +begin + CheckChangeBatchRowLimit; + FBatchRowLimit := aLimit; +end; + function TFBStatement.OpenCursor(aTransaction: ITransaction): IResultSet; begin Close; @@ -356,5 +432,15 @@ begin end; end; +function TFBStatement.IsInBatchMode: boolean; +begin + Result := false; +end; + +function TFBStatement.HasBatchMode: boolean; +begin + Result := false; +end; + end.