25 |
|
* |
26 |
|
*) |
27 |
|
unit FB30Statement; |
28 |
+ |
{$IFDEF MSWINDOWS} |
29 |
+ |
{$DEFINE WINDOWS} |
30 |
+ |
{$ENDIF} |
31 |
|
|
32 |
|
{$IFDEF FPC} |
33 |
< |
{$mode objfpc}{$H+} |
33 |
> |
{$mode delphi} |
34 |
|
{$codepage UTF8} |
35 |
|
{$interfaces COM} |
36 |
|
{$ENDIF} |
87 |
|
TIBXSQLVAR = class(TSQLVarData) |
88 |
|
private |
89 |
|
FStatement: TFB30Statement; |
90 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
91 |
|
FBlob: IBlob; {Cache references} |
92 |
|
FArray: IArray; |
93 |
|
FNullIndicator: short; |
98 |
|
{SQL Var Type Data} |
99 |
|
FSQLType: cardinal; |
100 |
|
FSQLSubType: integer; |
101 |
< |
FSQLData: PChar; {Address of SQL Data in Message Buffer} |
101 |
> |
FSQLData: PByte; {Address of SQL Data in Message Buffer} |
102 |
|
FSQLNullIndicator: PShort; {Address of null indicator} |
103 |
|
FDataLength: integer; |
104 |
|
FNullable: boolean; |
105 |
|
FScale: integer; |
106 |
|
FCharSetID: cardinal; |
107 |
< |
FRelationName: string; |
108 |
< |
FFieldName: string; |
107 |
> |
FRelationName: AnsiString; |
108 |
> |
FFieldName: AnsiString; |
109 |
|
|
110 |
|
protected |
111 |
|
function GetSQLType: cardinal; override; |
112 |
|
function GetSubtype: integer; override; |
113 |
< |
function GetAliasName: string; override; |
114 |
< |
function GetFieldName: string; override; |
115 |
< |
function GetOwnerName: string; override; |
116 |
< |
function GetRelationName: string; override; |
113 |
> |
function GetAliasName: AnsiString; override; |
114 |
> |
function GetFieldName: AnsiString; override; |
115 |
> |
function GetOwnerName: AnsiString; override; |
116 |
> |
function GetRelationName: AnsiString; override; |
117 |
|
function GetScale: integer; override; |
118 |
|
function GetCharSetID: cardinal; override; |
119 |
|
function GetCodePage: TSystemCodePage; override; |
120 |
|
function GetIsNull: Boolean; override; |
121 |
|
function GetIsNullable: boolean; override; |
122 |
< |
function GetSQLData: PChar; override; |
122 |
> |
function GetSQLData: PByte; override; |
123 |
|
function GetDataLength: cardinal; override; |
124 |
|
procedure SetIsNull(Value: Boolean); override; |
125 |
|
procedure SetIsNullable(Value: Boolean); override; |
126 |
< |
procedure SetSQLData(AValue: PChar; len: cardinal); override; |
126 |
> |
procedure SetSQLData(AValue: PByte; len: cardinal); override; |
127 |
|
procedure SetScale(aValue: integer); override; |
128 |
|
procedure SetDataLength(len: cardinal); override; |
129 |
|
procedure SetSQLType(aValue: cardinal); override; |
149 |
|
FSize: Integer; {Number of TIBXSQLVARs in column list} |
150 |
|
FMetaData: Firebird.IMessageMetadata; |
151 |
|
FTransactionSeqNo: integer; |
152 |
< |
protected |
152 |
> |
protected |
153 |
|
FStatement: TFB30Statement; |
154 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
155 |
|
function GetTransactionSeqNo: integer; override; |
156 |
|
procedure FreeXSQLDA; virtual; |
157 |
|
function GetStatement: IStatement; override; |
175 |
|
|
176 |
|
TIBXINPUTSQLDA = class(TIBXSQLDA) |
177 |
|
private |
178 |
< |
FMessageBuffer: PChar; {Message Buffer} |
178 |
> |
FMessageBuffer: PByte; {Message Buffer} |
179 |
|
FMsgLength: integer; {Message Buffer length} |
180 |
|
FCurMetaData: Firebird.IMessageMetadata; |
181 |
|
procedure FreeMessageBuffer; |
182 |
< |
function GetMessageBuffer: PChar; |
182 |
> |
function GetMessageBuffer: PByte; |
183 |
|
function GetMetaData: Firebird.IMessageMetadata; |
184 |
|
function GetModified: Boolean; |
185 |
|
function GetMsgLength: integer; |
186 |
+ |
procedure BuildMetadata; |
187 |
|
procedure PackBuffer; |
188 |
|
protected |
189 |
|
procedure FreeXSQLDA; override; |
194 |
|
procedure Changed; override; |
195 |
|
function IsInputDataArea: boolean; override; |
196 |
|
property MetaData: Firebird.IMessageMetadata read GetMetaData; |
197 |
< |
property MessageBuffer: PChar read GetMessageBuffer; |
197 |
> |
property MessageBuffer: PByte read GetMessageBuffer; |
198 |
|
property MsgLength: integer read GetMsgLength; |
199 |
|
end; |
200 |
|
|
203 |
|
TIBXOUTPUTSQLDA = class(TIBXSQLDA) |
204 |
|
private |
205 |
|
FTransaction: TFB30Transaction; {transaction used to execute the statement} |
206 |
< |
FMessageBuffer: PChar; {Message Buffer} |
206 |
> |
FMessageBuffer: PByte; {Message Buffer} |
207 |
|
FMsgLength: integer; {Message Buffer length} |
208 |
|
protected |
209 |
|
procedure FreeXSQLDA; override; |
210 |
|
public |
211 |
|
procedure Bind(aMetaData: Firebird.IMessageMetadata); |
212 |
|
procedure GetData(index: integer; var aIsNull: boolean; var len: short; |
213 |
< |
var data: PChar); override; |
213 |
> |
var data: PByte); override; |
214 |
|
function IsInputDataArea: boolean; override; |
215 |
< |
property MessageBuffer: PChar read FMessageBuffer; |
215 |
> |
property MessageBuffer: PByte read FMessageBuffer; |
216 |
|
property MsgLength: integer read FMsgLength; |
217 |
|
end; |
218 |
|
|
227 |
|
destructor Destroy; override; |
228 |
|
{IResultSet} |
229 |
|
function FetchNext: boolean; |
230 |
< |
function GetCursorName: string; |
230 |
> |
function GetCursorName: AnsiString; |
231 |
|
function GetTransaction: ITransaction; override; |
232 |
|
function IsEof: boolean; |
233 |
|
procedure Close; |
238 |
|
TFB30Statement = class(TFBStatement,IStatement) |
239 |
|
private |
240 |
|
FStatementIntf: Firebird.IStatement; |
241 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
242 |
|
FSQLParams: TIBXINPUTSQLDA; |
243 |
|
FSQLRecord: TIBXOUTPUTSQLDA; |
244 |
|
FResultSet: Firebird.IResultSet; |
249 |
|
procedure InternalPrepare; override; |
250 |
|
function InternalExecute(aTransaction: ITransaction): IResults; override; |
251 |
|
function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override; |
252 |
+ |
procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override; |
253 |
|
procedure FreeHandle; override; |
254 |
|
procedure InternalClose(Force: boolean); override; |
255 |
|
public |
256 |
|
constructor Create(Attachment: TFB30Attachment; Transaction: ITransaction; |
257 |
< |
sql: string; aSQLDialect: integer); |
257 |
> |
sql: AnsiString; aSQLDialect: integer); |
258 |
|
constructor CreateWithParameterNames(Attachment: TFB30Attachment; Transaction: ITransaction; |
259 |
< |
sql: string; aSQLDialect: integer; GenerateParamNames: boolean =false); |
259 |
> |
sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean =false; |
260 |
> |
CaseSensitiveParams: boolean=false); |
261 |
|
destructor Destroy; override; |
262 |
|
function FetchNext: boolean; |
263 |
|
property StatementIntf: Firebird.IStatement read FStatementIntf; |
266 |
|
{IStatement} |
267 |
|
function GetSQLParams: ISQLParams; override; |
268 |
|
function GetMetaData: IMetaData; override; |
269 |
< |
function GetPlan: String; |
269 |
> |
function GetPlan: AnsiString; |
270 |
|
function IsPrepared: boolean; |
271 |
|
function CreateBlob(column: TColumnMetaData): IBlob; override; |
272 |
|
function CreateArray(column: TColumnMetaData): IArray; override; |
276 |
|
|
277 |
|
implementation |
278 |
|
|
279 |
< |
uses IBUtils, FBMessages, FB30Blob, variants, FBArray, FB30Array; |
279 |
> |
uses IBUtils, FBMessages, FBBlob, FB30Blob, variants, FBArray, FB30Array; |
280 |
> |
|
281 |
> |
const |
282 |
> |
ISQL_COUNTERS = 'CurrentMemory, MaxMemory, RealTime, UserTime, Buffers, Reads, Writes, Fetches'; |
283 |
|
|
284 |
|
{ TIBXSQLVAR } |
285 |
|
|
299 |
|
Result := FSQLSubType; |
300 |
|
end; |
301 |
|
|
302 |
< |
function TIBXSQLVAR.GetAliasName: string; |
302 |
> |
function TIBXSQLVAR.GetAliasName: AnsiString; |
303 |
|
begin |
304 |
< |
with Firebird30ClientAPI do |
304 |
> |
with FFirebird30ClientAPI do |
305 |
|
begin |
306 |
|
result := strpas(TIBXSQLDA(Parent).MetaData.getAlias(StatusIntf,Index)); |
307 |
|
Check4DataBaseError; |
308 |
|
end; |
309 |
|
end; |
310 |
|
|
311 |
< |
function TIBXSQLVAR.GetFieldName: string; |
311 |
> |
function TIBXSQLVAR.GetFieldName: AnsiString; |
312 |
|
begin |
313 |
|
Result := FFieldName; |
314 |
|
end; |
315 |
|
|
316 |
< |
function TIBXSQLVAR.GetOwnerName: string; |
316 |
> |
function TIBXSQLVAR.GetOwnerName: AnsiString; |
317 |
|
begin |
318 |
< |
with Firebird30ClientAPI do |
318 |
> |
with FFirebird30ClientAPI do |
319 |
|
begin |
320 |
|
result := strpas(TIBXSQLDA(Parent).MetaData.getOwner(StatusIntf,Index)); |
321 |
|
Check4DataBaseError; |
322 |
|
end; |
323 |
|
end; |
324 |
|
|
325 |
< |
function TIBXSQLVAR.GetRelationName: string; |
325 |
> |
function TIBXSQLVAR.GetRelationName: AnsiString; |
326 |
|
begin |
327 |
|
Result := FRelationName; |
328 |
|
end; |
349 |
|
else |
350 |
|
result := FCharSetID; |
351 |
|
end; |
352 |
+ |
result := result; |
353 |
|
end; |
354 |
|
|
355 |
|
function TIBXSQLVAR.GetCodePage: TSystemCodePage; |
356 |
|
begin |
357 |
|
result := CP_NONE; |
358 |
< |
with Firebird30ClientAPI do |
358 |
> |
with Statement.GetAttachment do |
359 |
|
CharSetID2CodePage(GetCharSetID,result); |
360 |
|
end; |
361 |
|
|
369 |
|
Result := FSQLNullIndicator <> nil; |
370 |
|
end; |
371 |
|
|
372 |
< |
function TIBXSQLVAR.GetSQLData: PChar; |
372 |
> |
function TIBXSQLVAR.GetSQLData: PByte; |
373 |
|
begin |
374 |
|
Result := FSQLData; |
375 |
|
end; |
401 |
|
FStatement.GetTransaction as TFB30Transaction, |
402 |
|
GetRelationName,GetFieldName, |
403 |
|
GetSubType); |
404 |
+ |
(FBlobMetaData as TFBBlobMetaData).SetCharSetID(GetCharSetID); |
405 |
|
Result := FBlobMetaData; |
406 |
|
end; |
407 |
|
|
415 |
|
else |
416 |
|
if IsNullable then |
417 |
|
FNullIndicator := 0; |
418 |
+ |
Changed; |
419 |
|
end; |
420 |
|
|
421 |
|
procedure TIBXSQLVAR.SetIsNullable(Value: Boolean); |
428 |
|
end |
429 |
|
else |
430 |
|
FSQLNullIndicator := nil; |
431 |
+ |
Changed; |
432 |
|
end; |
433 |
|
|
434 |
< |
procedure TIBXSQLVAR.SetSQLData(AValue: PChar; len: cardinal); |
434 |
> |
procedure TIBXSQLVAR.SetSQLData(AValue: PByte; len: cardinal); |
435 |
|
begin |
436 |
|
if FOwnsSQLData then |
437 |
|
FreeMem(FSQLData); |
438 |
|
FSQLData := AValue; |
439 |
|
FDataLength := len; |
440 |
|
FOwnsSQLData := false; |
441 |
+ |
Changed; |
442 |
|
end; |
443 |
|
|
444 |
|
procedure TIBXSQLVAR.SetScale(aValue: integer); |
445 |
|
begin |
446 |
|
FScale := aValue; |
447 |
+ |
Changed; |
448 |
|
end; |
449 |
|
|
450 |
|
procedure TIBXSQLVAR.SetDataLength(len: cardinal); |
452 |
|
if not FOwnsSQLData then |
453 |
|
FSQLData := nil; |
454 |
|
FDataLength := len; |
455 |
< |
with Firebird30ClientAPI do |
455 |
> |
with FFirebird30ClientAPI do |
456 |
|
IBAlloc(FSQLData, 0, FDataLength); |
457 |
|
FOwnsSQLData := true; |
458 |
+ |
Changed; |
459 |
|
end; |
460 |
|
|
461 |
|
procedure TIBXSQLVAR.SetSQLType(aValue: cardinal); |
462 |
|
begin |
463 |
|
FSQLType := aValue; |
464 |
+ |
Changed; |
465 |
|
end; |
466 |
|
|
467 |
|
procedure TIBXSQLVAR.SetCharSetID(aValue: cardinal); |
468 |
|
begin |
469 |
|
FCharSetID := aValue; |
470 |
+ |
Changed; |
471 |
|
end; |
472 |
|
|
473 |
|
constructor TIBXSQLVAR.Create(aParent: TIBXSQLDA; aIndex: integer); |
474 |
|
begin |
475 |
|
inherited Create(aParent,aIndex); |
476 |
|
FStatement := aParent.Statement; |
477 |
+ |
FFirebird30ClientAPI := aParent.FFirebird30ClientAPI; |
478 |
|
end; |
479 |
|
|
480 |
|
procedure TIBXSQLVAR.RowChange; |
560 |
|
FResults.Column[i].RowChange; |
561 |
|
end; |
562 |
|
|
563 |
< |
function TResultSet.GetCursorName: string; |
563 |
> |
function TResultSet.GetCursorName: AnsiString; |
564 |
|
begin |
565 |
|
IBError(ibxeNotSupported,[nil]); |
566 |
|
Result := ''; |
612 |
|
FMsgLength := 0; |
613 |
|
end; |
614 |
|
|
615 |
< |
function TIBXINPUTSQLDA.GetMessageBuffer: PChar; |
615 |
> |
function TIBXINPUTSQLDA.GetMessageBuffer: PByte; |
616 |
|
begin |
617 |
|
PackBuffer; |
618 |
|
Result := FMessageBuffer; |
620 |
|
|
621 |
|
function TIBXINPUTSQLDA.GetMetaData: Firebird.IMessageMetadata; |
622 |
|
begin |
623 |
< |
PackBuffer; |
623 |
> |
BuildMetadata; |
624 |
|
Result := FCurMetaData; |
625 |
|
end; |
626 |
|
|
630 |
|
Result := FMsgLength; |
631 |
|
end; |
632 |
|
|
633 |
< |
procedure TIBXINPUTSQLDA.PackBuffer; |
633 |
> |
procedure TIBXINPUTSQLDA.BuildMetadata; |
634 |
|
var Builder: Firebird.IMetadataBuilder; |
635 |
|
i: integer; |
636 |
|
begin |
637 |
< |
if FMsgLength > 0 then Exit; |
638 |
< |
|
617 |
< |
with Firebird30ClientAPI do |
637 |
> |
if FCurMetaData = nil then |
638 |
> |
with FFirebird30ClientAPI do |
639 |
|
begin |
640 |
|
Builder := inherited MetaData.getBuilder(StatusIntf); |
641 |
|
Check4DataBaseError; |
659 |
|
finally |
660 |
|
Builder.release; |
661 |
|
end; |
662 |
+ |
end; |
663 |
+ |
end; |
664 |
+ |
|
665 |
+ |
procedure TIBXINPUTSQLDA.PackBuffer; |
666 |
+ |
var i: integer; |
667 |
+ |
begin |
668 |
+ |
BuildMetadata; |
669 |
|
|
670 |
+ |
if FMsgLength = 0 then |
671 |
+ |
with FFirebird30ClientAPI do |
672 |
+ |
begin |
673 |
|
FMsgLength := FCurMetaData.getMessageLength(StatusIntf); |
674 |
|
Check4DataBaseError; |
675 |
|
|
678 |
|
for i := 0 to Count - 1 do |
679 |
|
with TIBXSQLVar(Column[i]) do |
680 |
|
begin |
681 |
< |
Move(FSQLData^,(FMessageBuffer + FCurMetaData.getOffset(StatusIntf,i))^,FDataLength); |
681 |
> |
if not Modified then |
682 |
> |
IBError(ibxeUninitializedInputParameter,[i,Name]); |
683 |
> |
|
684 |
> |
if IsNull then |
685 |
> |
FillChar((FMessageBuffer + FCurMetaData.getOffset(StatusIntf,i))^,FDataLength,0) |
686 |
> |
else |
687 |
> |
if FSQLData <> nil then |
688 |
> |
Move(FSQLData^,(FMessageBuffer + FCurMetaData.getOffset(StatusIntf,i))^,FDataLength); |
689 |
|
Check4DataBaseError; |
690 |
|
if IsNullable then |
691 |
|
begin |
718 |
|
var i: integer; |
719 |
|
begin |
720 |
|
FMetaData := aMetaData; |
721 |
< |
with Firebird30ClientAPI do |
721 |
> |
with FFirebird30ClientAPI do |
722 |
|
begin |
723 |
|
Count := metadata.getCount(StatusIntf); |
724 |
|
Check4DataBaseError; |
750 |
|
else |
751 |
|
IBAlloc(FSQLData, 0, FDataLength) |
752 |
|
end; |
753 |
< |
SQL_VARYING: begin |
753 |
> |
SQL_VARYING: |
754 |
|
IBAlloc(FSQLData, 0, FDataLength + 2); |
717 |
– |
end; |
755 |
|
else |
756 |
|
IBError(ibxeUnknownSQLDataType, [sqltype and (not 1)]) |
757 |
|
end; |
765 |
|
FSQLNullIndicator := nil; |
766 |
|
FScale := aMetaData.getScale(StatusIntf,i); |
767 |
|
Check4DataBaseError; |
768 |
< |
FCharSetID := aMetaData.getCharSet(StatusIntf,i); |
768 |
> |
FCharSetID := aMetaData.getCharSet(StatusIntf,i) and $FF; |
769 |
|
Check4DataBaseError; |
770 |
|
end; |
771 |
|
end; |
796 |
|
var i: integer; |
797 |
|
begin |
798 |
|
FMetaData := aMetaData; |
799 |
< |
with Firebird30ClientAPI do |
799 |
> |
with FFirebird30ClientAPI do |
800 |
|
begin |
801 |
|
Count := metadata.getCount(StatusIntf); |
802 |
|
Check4DataBaseError; |
839 |
|
FSQLNullIndicator := nil; |
840 |
|
FScale := aMetaData.getScale(StatusIntf,i); |
841 |
|
Check4DataBaseError; |
842 |
< |
FCharSetID := aMetaData.getCharSet(StatusIntf,i); |
842 |
> |
FCharSetID := aMetaData.getCharSet(StatusIntf,i) and $FF; |
843 |
|
Check4DataBaseError; |
844 |
|
end; |
845 |
|
end; |
847 |
|
end; |
848 |
|
|
849 |
|
procedure TIBXOUTPUTSQLDA.GetData(index: integer; var aIsNull: boolean; |
850 |
< |
var len: short; var data: PChar); |
850 |
> |
var len: short; var data: PByte); |
851 |
|
begin |
852 |
|
with TIBXSQLVAR(Column[index]) do |
853 |
|
begin |
856 |
|
len := FDataLength; |
857 |
|
if not IsNull and (FSQLType = SQL_VARYING) then |
858 |
|
begin |
859 |
< |
with Firebird30ClientAPI do |
859 |
> |
with FFirebird30ClientAPI do |
860 |
|
len := DecodeInteger(data,2); |
861 |
|
Inc(Data,2); |
862 |
|
end; |
873 |
|
begin |
874 |
|
inherited Create; |
875 |
|
FStatement := aStatement; |
876 |
+ |
FFirebird30ClientAPI := aStatement.FFirebird30ClientAPI; |
877 |
|
FSize := 0; |
878 |
|
// writeln('Creating ',ClassName); |
879 |
|
end; |
990 |
|
procedure TFB30Statement.GetDSQLInfo(info_request: byte; buffer: ISQLInfoResults |
991 |
|
); |
992 |
|
begin |
993 |
< |
with Firebird30ClientAPI, buffer as TSQLInfoResultsBuffer do |
993 |
> |
with FFirebird30ClientAPI, buffer as TSQLInfoResultsBuffer do |
994 |
|
begin |
995 |
|
StatementIntf.getInfo(StatusIntf,1,BytePtr(@info_request), |
996 |
|
GetBufSize, BytePtr(Buffer)); |
1006 |
|
IBError(ibxeEmptyQuery, [nil]); |
1007 |
|
try |
1008 |
|
CheckTransaction(FTransactionIntf); |
1009 |
< |
with Firebird30ClientAPI do |
1009 |
> |
with FFirebird30ClientAPI do |
1010 |
|
begin |
1011 |
|
if FHasParamNames then |
1012 |
|
begin |
1013 |
|
if FProcessedSQL = '' then |
1014 |
< |
FSQLParams.PreprocessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
1014 |
> |
ProcessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
1015 |
|
FStatementIntf := (GetAttachment as TFB30Attachment).AttachmentIntf.prepare(StatusIntf, |
1016 |
|
(FTransactionIntf as TFB30Transaction).TransactionIntf, |
1017 |
|
Length(FProcessedSQL), |
1018 |
< |
PChar(FProcessedSQL), |
1018 |
> |
PAnsiChar(FProcessedSQL), |
1019 |
|
FSQLDialect, |
1020 |
|
Firebird.IStatement.PREPARE_PREFETCH_METADATA); |
1021 |
|
end |
1023 |
|
FStatementIntf := (GetAttachment as TFB30Attachment).AttachmentIntf.prepare(StatusIntf, |
1024 |
|
(FTransactionIntf as TFB30Transaction).TransactionIntf, |
1025 |
|
Length(FSQL), |
1026 |
< |
PChar(FSQL), |
1026 |
> |
PAnsiChar(FSQL), |
1027 |
|
FSQLDialect, |
1028 |
|
Firebird.IStatement.PREPARE_PREFETCH_METADATA); |
1029 |
|
Check4DataBaseError; |
1103 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1104 |
|
|
1105 |
|
try |
1106 |
< |
with Firebird30ClientAPI do |
1069 |
< |
case FSQLStatementType of |
1070 |
< |
SQLSelect: |
1071 |
< |
IBError(ibxeIsAExecuteProcedure,[]); |
1072 |
< |
|
1073 |
< |
SQLExecProcedure: |
1106 |
> |
with FFirebird30ClientAPI do |
1107 |
|
begin |
1108 |
< |
FStatementIntf.execute(StatusIntf, |
1109 |
< |
(aTransaction as TFB30Transaction).TransactionIntf, |
1110 |
< |
FSQLParams.MetaData, |
1111 |
< |
FSQLParams.MessageBuffer, |
1112 |
< |
FSQLRecord.MetaData, |
1113 |
< |
FSQLRecord.MessageBuffer); |
1114 |
< |
Check4DataBaseError; |
1108 |
> |
if FCollectStatistics then |
1109 |
> |
begin |
1110 |
> |
UtilIntf.getPerfCounters(StatusIntf, |
1111 |
> |
(GetAttachment as TFB30Attachment).AttachmentIntf, |
1112 |
> |
ISQL_COUNTERS,@FBeforeStats); |
1113 |
> |
Check4DataBaseError; |
1114 |
> |
end; |
1115 |
|
|
1116 |
< |
Result := TResults.Create(FSQLRecord); |
1117 |
< |
FSingleResults := true; |
1118 |
< |
end |
1119 |
< |
else |
1120 |
< |
FStatementIntf.execute(StatusIntf, |
1121 |
< |
(aTransaction as TFB30Transaction).TransactionIntf, |
1122 |
< |
FSQLParams.MetaData, |
1123 |
< |
FSQLParams.MessageBuffer, |
1124 |
< |
nil, |
1125 |
< |
nil); |
1126 |
< |
Check4DataBaseError; |
1116 |
> |
case FSQLStatementType of |
1117 |
> |
SQLSelect: |
1118 |
> |
IBError(ibxeIsAExecuteProcedure,[]); |
1119 |
> |
|
1120 |
> |
SQLExecProcedure: |
1121 |
> |
begin |
1122 |
> |
FStatementIntf.execute(StatusIntf, |
1123 |
> |
(aTransaction as TFB30Transaction).TransactionIntf, |
1124 |
> |
FSQLParams.MetaData, |
1125 |
> |
FSQLParams.MessageBuffer, |
1126 |
> |
FSQLRecord.MetaData, |
1127 |
> |
FSQLRecord.MessageBuffer); |
1128 |
> |
Check4DataBaseError; |
1129 |
> |
|
1130 |
> |
Result := TResults.Create(FSQLRecord); |
1131 |
> |
FSingleResults := true; |
1132 |
> |
end |
1133 |
> |
else |
1134 |
> |
FStatementIntf.execute(StatusIntf, |
1135 |
> |
(aTransaction as TFB30Transaction).TransactionIntf, |
1136 |
> |
FSQLParams.MetaData, |
1137 |
> |
FSQLParams.MessageBuffer, |
1138 |
> |
nil, |
1139 |
> |
nil); |
1140 |
> |
Check4DataBaseError; |
1141 |
> |
end; |
1142 |
> |
if FCollectStatistics then |
1143 |
> |
begin |
1144 |
> |
UtilIntf.getPerfCounters(StatusIntf, |
1145 |
> |
(GetAttachment as TFB30Attachment).AttachmentIntf, |
1146 |
> |
ISQL_COUNTERS, @FAfterStats); |
1147 |
> |
Check4DataBaseError; |
1148 |
> |
FStatisticsAvailable := true; |
1149 |
> |
end; |
1150 |
|
end; |
1151 |
|
finally |
1152 |
|
if aTransaction <> FTransactionIntf then |
1153 |
|
RemoveMonitor(aTransaction as TFB30Transaction); |
1154 |
|
end; |
1155 |
|
FExecTransactionIntf := aTransaction; |
1156 |
+ |
FSQLRecord.FTransaction := (aTransaction as TFB30Transaction); |
1157 |
+ |
FSQLRecord.FTransactionSeqNo := FSQLRecord.FTransaction.TransactionSeqNo; |
1158 |
|
SignalActivity; |
1159 |
|
Inc(FChangeSeqNo); |
1160 |
|
end; |
1174 |
|
if (FSQLParams.FTransactionSeqNo < (FTransactionIntf as TFB30transaction).TransactionSeqNo) then |
1175 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1176 |
|
|
1177 |
< |
with Firebird30ClientAPI do |
1177 |
> |
with FFirebird30ClientAPI do |
1178 |
|
begin |
1179 |
+ |
if FCollectStatistics then |
1180 |
+ |
begin |
1181 |
+ |
UtilIntf.getPerfCounters(StatusIntf, |
1182 |
+ |
(GetAttachment as TFB30Attachment).AttachmentIntf, |
1183 |
+ |
ISQL_COUNTERS, @FBeforeStats); |
1184 |
+ |
Check4DataBaseError; |
1185 |
+ |
end; |
1186 |
+ |
|
1187 |
|
FResultSet := FStatementIntf.openCursor(StatusIntf, |
1188 |
|
(aTransaction as TFB30Transaction).TransactionIntf, |
1189 |
|
FSQLParams.MetaData, |
1191 |
|
FSQLRecord.MetaData, |
1192 |
|
0); |
1193 |
|
Check4DataBaseError; |
1194 |
+ |
|
1195 |
+ |
if FCollectStatistics then |
1196 |
+ |
begin |
1197 |
+ |
UtilIntf.getPerfCounters(StatusIntf, |
1198 |
+ |
(GetAttachment as TFB30Attachment).AttachmentIntf, |
1199 |
+ |
ISQL_COUNTERS,@FAfterStats); |
1200 |
+ |
Check4DataBaseError; |
1201 |
+ |
FStatisticsAvailable := true; |
1202 |
+ |
end; |
1203 |
|
end; |
1204 |
|
Inc(FCursorSeqNo); |
1205 |
|
FSingleResults := false; |
1214 |
|
Inc(FChangeSeqNo); |
1215 |
|
end; |
1216 |
|
|
1217 |
+ |
procedure TFB30Statement.ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; |
1218 |
+ |
var processedSQL: AnsiString); |
1219 |
+ |
begin |
1220 |
+ |
FSQLParams.PreprocessSQL(sql,GenerateParamNames,processedSQL); |
1221 |
+ |
end; |
1222 |
+ |
|
1223 |
|
procedure TFB30Statement.FreeHandle; |
1224 |
|
begin |
1225 |
|
Close; |
1236 |
|
begin |
1237 |
|
if (FStatementIntf <> nil) and (SQLStatementType = SQLSelect) and FOpen then |
1238 |
|
try |
1239 |
< |
with Firebird30ClientAPI do |
1239 |
> |
with FFirebird30ClientAPI do |
1240 |
|
begin |
1241 |
|
if FResultSet <> nil then |
1242 |
|
begin |
1250 |
|
if not Force then Check4DataBaseError; |
1251 |
|
end; |
1252 |
|
finally |
1253 |
< |
if (FSQLRecord.FTransaction <> nil) and (FSQLRecord.FTransaction <> FTransactionIntf) then |
1253 |
> |
if (FSQLRecord.FTransaction <> nil) and (FSQLRecord.FTransaction <> (FTransactionIntf as TFB30Transaction)) then |
1254 |
|
RemoveMonitor(FSQLRecord.FTransaction); |
1255 |
|
FOpen := False; |
1256 |
|
FExecTransactionIntf := nil; |
1261 |
|
end; |
1262 |
|
|
1263 |
|
constructor TFB30Statement.Create(Attachment: TFB30Attachment; |
1264 |
< |
Transaction: ITransaction; sql: string; aSQLDialect: integer); |
1264 |
> |
Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer); |
1265 |
|
begin |
1266 |
|
inherited Create(Attachment,Transaction,sql,aSQLDialect); |
1267 |
+ |
FFirebird30ClientAPI := Attachment.Firebird30ClientAPI; |
1268 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1269 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1270 |
|
InternalPrepare; |
1271 |
|
end; |
1272 |
|
|
1273 |
|
constructor TFB30Statement.CreateWithParameterNames( |
1274 |
< |
Attachment: TFB30Attachment; Transaction: ITransaction; sql: string; |
1275 |
< |
aSQLDialect: integer; GenerateParamNames: boolean); |
1274 |
> |
Attachment: TFB30Attachment; Transaction: ITransaction; sql: AnsiString; |
1275 |
> |
aSQLDialect: integer; GenerateParamNames: boolean; |
1276 |
> |
CaseSensitiveParams: boolean); |
1277 |
|
begin |
1278 |
|
inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames); |
1279 |
+ |
FFirebird30ClientAPI := Attachment.Firebird30ClientAPI; |
1280 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1281 |
+ |
FSQLParams.CaseSensitiveParams := CaseSensitiveParams; |
1282 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1283 |
|
InternalPrepare; |
1284 |
|
end; |
1299 |
|
if FEOF then |
1300 |
|
IBError(ibxeEOF,[nil]); |
1301 |
|
|
1302 |
< |
with Firebird30ClientAPI do |
1302 |
> |
with FFirebird30ClientAPI do |
1303 |
|
begin |
1304 |
|
{ Go to the next record... } |
1305 |
|
fetchResult := FResultSet.fetchNext(StatusIntf,FSQLRecord.MessageBuffer); |
1324 |
|
FBOF := false; |
1325 |
|
result := true; |
1326 |
|
end; |
1327 |
+ |
if FCollectStatistics then |
1328 |
+ |
begin |
1329 |
+ |
UtilIntf.getPerfCounters(StatusIntf, |
1330 |
+ |
(GetAttachment as TFB30Attachment).AttachmentIntf, |
1331 |
+ |
ISQL_COUNTERS,@FAfterStats); |
1332 |
+ |
Check4DataBaseError; |
1333 |
+ |
FStatisticsAvailable := true; |
1334 |
+ |
end; |
1335 |
|
end; |
1336 |
|
FSQLRecord.RowChange; |
1337 |
|
SignalActivity; |
1355 |
|
Result := TMetaData(GetInterface(1)); |
1356 |
|
end; |
1357 |
|
|
1358 |
< |
function TFB30Statement.GetPlan: String; |
1358 |
> |
function TFB30Statement.GetPlan: AnsiString; |
1359 |
|
begin |
1360 |
|
CheckHandle; |
1361 |
|
if (not (FSQLStatementType in [SQLSelect, SQLSelectForUpdate, |
1363 |
|
SQLUpdate, SQLDelete])) then |
1364 |
|
result := '' |
1365 |
|
else |
1366 |
< |
with Firebird30ClientAPI do |
1366 |
> |
with FFirebird30ClientAPI do |
1367 |
|
begin |
1368 |
|
Result := FStatementIntf.getPlan(StatusIntf,true); |
1369 |
|
Check4DataBaseError; |