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 GetCharSetWidth: integer; override; |
121 |
|
function GetIsNull: Boolean; override; |
122 |
|
function GetIsNullable: boolean; override; |
123 |
< |
function GetSQLData: PChar; override; |
123 |
> |
function GetSQLData: PByte; override; |
124 |
|
function GetDataLength: cardinal; override; |
125 |
|
procedure SetIsNull(Value: Boolean); override; |
126 |
|
procedure SetIsNullable(Value: Boolean); override; |
127 |
< |
procedure SetSQLData(AValue: PChar; len: cardinal); override; |
127 |
> |
procedure SetSQLData(AValue: PByte; len: cardinal); override; |
128 |
|
procedure SetScale(aValue: integer); override; |
129 |
|
procedure SetDataLength(len: cardinal); override; |
130 |
|
procedure SetSQLType(aValue: cardinal); override; |
150 |
|
FSize: Integer; {Number of TIBXSQLVARs in column list} |
151 |
|
FMetaData: Firebird.IMessageMetadata; |
152 |
|
FTransactionSeqNo: integer; |
153 |
< |
protected |
153 |
> |
protected |
154 |
|
FStatement: TFB30Statement; |
155 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
156 |
|
function GetTransactionSeqNo: integer; override; |
157 |
|
procedure FreeXSQLDA; virtual; |
158 |
|
function GetStatement: IStatement; override; |
176 |
|
|
177 |
|
TIBXINPUTSQLDA = class(TIBXSQLDA) |
178 |
|
private |
179 |
< |
FMessageBuffer: PChar; {Message Buffer} |
179 |
> |
FMessageBuffer: PByte; {Message Buffer} |
180 |
|
FMsgLength: integer; {Message Buffer length} |
181 |
|
FCurMetaData: Firebird.IMessageMetadata; |
182 |
|
procedure FreeMessageBuffer; |
183 |
< |
function GetMessageBuffer: PChar; |
183 |
> |
function GetMessageBuffer: PByte; |
184 |
|
function GetMetaData: Firebird.IMessageMetadata; |
185 |
|
function GetModified: Boolean; |
186 |
|
function GetMsgLength: integer; |
187 |
+ |
procedure BuildMetadata; |
188 |
|
procedure PackBuffer; |
189 |
|
protected |
190 |
|
procedure FreeXSQLDA; override; |
195 |
|
procedure Changed; override; |
196 |
|
function IsInputDataArea: boolean; override; |
197 |
|
property MetaData: Firebird.IMessageMetadata read GetMetaData; |
198 |
< |
property MessageBuffer: PChar read GetMessageBuffer; |
198 |
> |
property MessageBuffer: PByte read GetMessageBuffer; |
199 |
|
property MsgLength: integer read GetMsgLength; |
200 |
|
end; |
201 |
|
|
204 |
|
TIBXOUTPUTSQLDA = class(TIBXSQLDA) |
205 |
|
private |
206 |
|
FTransaction: TFB30Transaction; {transaction used to execute the statement} |
207 |
< |
FMessageBuffer: PChar; {Message Buffer} |
207 |
> |
FMessageBuffer: PByte; {Message Buffer} |
208 |
|
FMsgLength: integer; {Message Buffer length} |
209 |
|
protected |
210 |
|
procedure FreeXSQLDA; override; |
211 |
|
public |
212 |
|
procedure Bind(aMetaData: Firebird.IMessageMetadata); |
213 |
|
procedure GetData(index: integer; var aIsNull: boolean; var len: short; |
214 |
< |
var data: PChar); override; |
214 |
> |
var data: PByte); override; |
215 |
|
function IsInputDataArea: boolean; override; |
216 |
< |
property MessageBuffer: PChar read FMessageBuffer; |
216 |
> |
property MessageBuffer: PByte read FMessageBuffer; |
217 |
|
property MsgLength: integer read FMsgLength; |
218 |
|
end; |
219 |
|
|
228 |
|
destructor Destroy; override; |
229 |
|
{IResultSet} |
230 |
|
function FetchNext: boolean; |
231 |
< |
function GetCursorName: string; |
231 |
> |
function GetCursorName: AnsiString; |
232 |
|
function GetTransaction: ITransaction; override; |
233 |
|
function IsEof: boolean; |
234 |
|
procedure Close; |
239 |
|
TFB30Statement = class(TFBStatement,IStatement) |
240 |
|
private |
241 |
|
FStatementIntf: Firebird.IStatement; |
242 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
243 |
|
FSQLParams: TIBXINPUTSQLDA; |
244 |
|
FSQLRecord: TIBXOUTPUTSQLDA; |
245 |
|
FResultSet: Firebird.IResultSet; |
250 |
|
procedure InternalPrepare; override; |
251 |
|
function InternalExecute(aTransaction: ITransaction): IResults; override; |
252 |
|
function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override; |
253 |
+ |
procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override; |
254 |
|
procedure FreeHandle; override; |
255 |
|
procedure InternalClose(Force: boolean); override; |
256 |
|
public |
257 |
|
constructor Create(Attachment: TFB30Attachment; Transaction: ITransaction; |
258 |
< |
sql: string; aSQLDialect: integer); |
258 |
> |
sql: AnsiString; aSQLDialect: integer); |
259 |
|
constructor CreateWithParameterNames(Attachment: TFB30Attachment; Transaction: ITransaction; |
260 |
< |
sql: string; aSQLDialect: integer; GenerateParamNames: boolean =false); |
260 |
> |
sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean =false; |
261 |
> |
CaseSensitiveParams: boolean=false); |
262 |
|
destructor Destroy; override; |
263 |
|
function FetchNext: boolean; |
264 |
|
property StatementIntf: Firebird.IStatement read FStatementIntf; |
267 |
|
{IStatement} |
268 |
|
function GetSQLParams: ISQLParams; override; |
269 |
|
function GetMetaData: IMetaData; override; |
270 |
< |
function GetPlan: String; |
270 |
> |
function GetPlan: AnsiString; |
271 |
|
function IsPrepared: boolean; |
272 |
|
function CreateBlob(column: TColumnMetaData): IBlob; override; |
273 |
|
function CreateArray(column: TColumnMetaData): IArray; override; |
277 |
|
|
278 |
|
implementation |
279 |
|
|
280 |
< |
uses IBUtils, FBMessages, FBBLob, FB30Blob, variants, FBArray, FB30Array; |
280 |
> |
uses IBUtils, FBMessages, FBBlob, FB30Blob, variants, FBArray, FB30Array; |
281 |
|
|
282 |
|
const |
283 |
|
ISQL_COUNTERS = 'CurrentMemory, MaxMemory, RealTime, UserTime, Buffers, Reads, Writes, Fetches'; |
300 |
|
Result := FSQLSubType; |
301 |
|
end; |
302 |
|
|
303 |
< |
function TIBXSQLVAR.GetAliasName: string; |
303 |
> |
function TIBXSQLVAR.GetAliasName: AnsiString; |
304 |
|
begin |
305 |
< |
with Firebird30ClientAPI do |
305 |
> |
with FFirebird30ClientAPI do |
306 |
|
begin |
307 |
|
result := strpas(TIBXSQLDA(Parent).MetaData.getAlias(StatusIntf,Index)); |
308 |
|
Check4DataBaseError; |
309 |
|
end; |
310 |
|
end; |
311 |
|
|
312 |
< |
function TIBXSQLVAR.GetFieldName: string; |
312 |
> |
function TIBXSQLVAR.GetFieldName: AnsiString; |
313 |
|
begin |
314 |
|
Result := FFieldName; |
315 |
|
end; |
316 |
|
|
317 |
< |
function TIBXSQLVAR.GetOwnerName: string; |
317 |
> |
function TIBXSQLVAR.GetOwnerName: AnsiString; |
318 |
|
begin |
319 |
< |
with Firebird30ClientAPI do |
319 |
> |
with FFirebird30ClientAPI do |
320 |
|
begin |
321 |
|
result := strpas(TIBXSQLDA(Parent).MetaData.getOwner(StatusIntf,Index)); |
322 |
|
Check4DataBaseError; |
323 |
|
end; |
324 |
|
end; |
325 |
|
|
326 |
< |
function TIBXSQLVAR.GetRelationName: string; |
326 |
> |
function TIBXSQLVAR.GetRelationName: AnsiString; |
327 |
|
begin |
328 |
|
Result := FRelationName; |
329 |
|
end; |
350 |
|
else |
351 |
|
result := FCharSetID; |
352 |
|
end; |
353 |
+ |
result := result; |
354 |
|
end; |
355 |
|
|
356 |
|
function TIBXSQLVAR.GetCodePage: TSystemCodePage; |
357 |
|
begin |
358 |
|
result := CP_NONE; |
359 |
< |
with Firebird30ClientAPI do |
359 |
> |
with Statement.GetAttachment do |
360 |
|
CharSetID2CodePage(GetCharSetID,result); |
361 |
|
end; |
362 |
|
|
363 |
+ |
function TIBXSQLVAR.GetCharSetWidth: integer; |
364 |
+ |
begin |
365 |
+ |
result := 1; |
366 |
+ |
with Statement.GetAttachment DO |
367 |
+ |
CharSetWidth(GetCharSetID,result); |
368 |
+ |
end; |
369 |
+ |
|
370 |
|
function TIBXSQLVAR.GetIsNull: Boolean; |
371 |
|
begin |
372 |
|
Result := IsNullable and (FSQLNullIndicator^ = -1); |
377 |
|
Result := FSQLNullIndicator <> nil; |
378 |
|
end; |
379 |
|
|
380 |
< |
function TIBXSQLVAR.GetSQLData: PChar; |
380 |
> |
function TIBXSQLVAR.GetSQLData: PByte; |
381 |
|
begin |
382 |
|
Result := FSQLData; |
383 |
|
end; |
436 |
|
end |
437 |
|
else |
438 |
|
FSQLNullIndicator := nil; |
439 |
+ |
Changed; |
440 |
|
end; |
441 |
|
|
442 |
< |
procedure TIBXSQLVAR.SetSQLData(AValue: PChar; len: cardinal); |
442 |
> |
procedure TIBXSQLVAR.SetSQLData(AValue: PByte; len: cardinal); |
443 |
|
begin |
444 |
|
if FOwnsSQLData then |
445 |
|
FreeMem(FSQLData); |
446 |
|
FSQLData := AValue; |
447 |
|
FDataLength := len; |
448 |
|
FOwnsSQLData := false; |
449 |
+ |
Changed; |
450 |
|
end; |
451 |
|
|
452 |
|
procedure TIBXSQLVAR.SetScale(aValue: integer); |
453 |
|
begin |
454 |
|
FScale := aValue; |
455 |
+ |
Changed; |
456 |
|
end; |
457 |
|
|
458 |
|
procedure TIBXSQLVAR.SetDataLength(len: cardinal); |
460 |
|
if not FOwnsSQLData then |
461 |
|
FSQLData := nil; |
462 |
|
FDataLength := len; |
463 |
< |
with Firebird30ClientAPI do |
463 |
> |
with FFirebird30ClientAPI do |
464 |
|
IBAlloc(FSQLData, 0, FDataLength); |
465 |
|
FOwnsSQLData := true; |
466 |
+ |
Changed; |
467 |
|
end; |
468 |
|
|
469 |
|
procedure TIBXSQLVAR.SetSQLType(aValue: cardinal); |
470 |
|
begin |
471 |
|
FSQLType := aValue; |
472 |
+ |
Changed; |
473 |
|
end; |
474 |
|
|
475 |
|
procedure TIBXSQLVAR.SetCharSetID(aValue: cardinal); |
476 |
|
begin |
477 |
|
FCharSetID := aValue; |
478 |
+ |
Changed; |
479 |
|
end; |
480 |
|
|
481 |
|
constructor TIBXSQLVAR.Create(aParent: TIBXSQLDA; aIndex: integer); |
482 |
|
begin |
483 |
|
inherited Create(aParent,aIndex); |
484 |
|
FStatement := aParent.Statement; |
485 |
+ |
FFirebird30ClientAPI := aParent.FFirebird30ClientAPI; |
486 |
|
end; |
487 |
|
|
488 |
|
procedure TIBXSQLVAR.RowChange; |
568 |
|
FResults.Column[i].RowChange; |
569 |
|
end; |
570 |
|
|
571 |
< |
function TResultSet.GetCursorName: string; |
571 |
> |
function TResultSet.GetCursorName: AnsiString; |
572 |
|
begin |
573 |
|
IBError(ibxeNotSupported,[nil]); |
574 |
|
Result := ''; |
620 |
|
FMsgLength := 0; |
621 |
|
end; |
622 |
|
|
623 |
< |
function TIBXINPUTSQLDA.GetMessageBuffer: PChar; |
623 |
> |
function TIBXINPUTSQLDA.GetMessageBuffer: PByte; |
624 |
|
begin |
625 |
|
PackBuffer; |
626 |
|
Result := FMessageBuffer; |
628 |
|
|
629 |
|
function TIBXINPUTSQLDA.GetMetaData: Firebird.IMessageMetadata; |
630 |
|
begin |
631 |
< |
PackBuffer; |
631 |
> |
BuildMetadata; |
632 |
|
Result := FCurMetaData; |
633 |
|
end; |
634 |
|
|
638 |
|
Result := FMsgLength; |
639 |
|
end; |
640 |
|
|
641 |
< |
procedure TIBXINPUTSQLDA.PackBuffer; |
641 |
> |
procedure TIBXINPUTSQLDA.BuildMetadata; |
642 |
|
var Builder: Firebird.IMetadataBuilder; |
643 |
|
i: integer; |
644 |
|
begin |
645 |
< |
if FMsgLength > 0 then Exit; |
646 |
< |
|
622 |
< |
with Firebird30ClientAPI do |
645 |
> |
if FCurMetaData = nil then |
646 |
> |
with FFirebird30ClientAPI do |
647 |
|
begin |
648 |
|
Builder := inherited MetaData.getBuilder(StatusIntf); |
649 |
|
Check4DataBaseError; |
667 |
|
finally |
668 |
|
Builder.release; |
669 |
|
end; |
670 |
+ |
end; |
671 |
+ |
end; |
672 |
|
|
673 |
+ |
procedure TIBXINPUTSQLDA.PackBuffer; |
674 |
+ |
var i: integer; |
675 |
+ |
begin |
676 |
+ |
BuildMetadata; |
677 |
+ |
|
678 |
+ |
if FMsgLength = 0 then |
679 |
+ |
with FFirebird30ClientAPI do |
680 |
+ |
begin |
681 |
|
FMsgLength := FCurMetaData.getMessageLength(StatusIntf); |
682 |
|
Check4DataBaseError; |
683 |
|
|
686 |
|
for i := 0 to Count - 1 do |
687 |
|
with TIBXSQLVar(Column[i]) do |
688 |
|
begin |
689 |
+ |
if not Modified then |
690 |
+ |
IBError(ibxeUninitializedInputParameter,[i,Name]); |
691 |
+ |
|
692 |
|
if IsNull then |
693 |
|
FillChar((FMessageBuffer + FCurMetaData.getOffset(StatusIntf,i))^,FDataLength,0) |
694 |
|
else |
695 |
+ |
if FSQLData <> nil then |
696 |
|
Move(FSQLData^,(FMessageBuffer + FCurMetaData.getOffset(StatusIntf,i))^,FDataLength); |
697 |
|
Check4DataBaseError; |
698 |
|
if IsNullable then |
726 |
|
var i: integer; |
727 |
|
begin |
728 |
|
FMetaData := aMetaData; |
729 |
< |
with Firebird30ClientAPI do |
729 |
> |
with FFirebird30ClientAPI do |
730 |
|
begin |
731 |
|
Count := metadata.getCount(StatusIntf); |
732 |
|
Check4DataBaseError; |
773 |
|
FSQLNullIndicator := nil; |
774 |
|
FScale := aMetaData.getScale(StatusIntf,i); |
775 |
|
Check4DataBaseError; |
776 |
< |
FCharSetID := aMetaData.getCharSet(StatusIntf,i); |
776 |
> |
FCharSetID := aMetaData.getCharSet(StatusIntf,i) and $FF; |
777 |
|
Check4DataBaseError; |
778 |
|
end; |
779 |
|
end; |
804 |
|
var i: integer; |
805 |
|
begin |
806 |
|
FMetaData := aMetaData; |
807 |
< |
with Firebird30ClientAPI do |
807 |
> |
with FFirebird30ClientAPI do |
808 |
|
begin |
809 |
|
Count := metadata.getCount(StatusIntf); |
810 |
|
Check4DataBaseError; |
847 |
|
FSQLNullIndicator := nil; |
848 |
|
FScale := aMetaData.getScale(StatusIntf,i); |
849 |
|
Check4DataBaseError; |
850 |
< |
FCharSetID := aMetaData.getCharSet(StatusIntf,i); |
850 |
> |
FCharSetID := aMetaData.getCharSet(StatusIntf,i) and $FF; |
851 |
|
Check4DataBaseError; |
852 |
|
end; |
853 |
|
end; |
855 |
|
end; |
856 |
|
|
857 |
|
procedure TIBXOUTPUTSQLDA.GetData(index: integer; var aIsNull: boolean; |
858 |
< |
var len: short; var data: PChar); |
858 |
> |
var len: short; var data: PByte); |
859 |
|
begin |
860 |
|
with TIBXSQLVAR(Column[index]) do |
861 |
|
begin |
864 |
|
len := FDataLength; |
865 |
|
if not IsNull and (FSQLType = SQL_VARYING) then |
866 |
|
begin |
867 |
< |
with Firebird30ClientAPI do |
867 |
> |
with FFirebird30ClientAPI do |
868 |
|
len := DecodeInteger(data,2); |
869 |
|
Inc(Data,2); |
870 |
|
end; |
881 |
|
begin |
882 |
|
inherited Create; |
883 |
|
FStatement := aStatement; |
884 |
+ |
FFirebird30ClientAPI := aStatement.FFirebird30ClientAPI; |
885 |
|
FSize := 0; |
886 |
|
// writeln('Creating ',ClassName); |
887 |
|
end; |
998 |
|
procedure TFB30Statement.GetDSQLInfo(info_request: byte; buffer: ISQLInfoResults |
999 |
|
); |
1000 |
|
begin |
1001 |
< |
with Firebird30ClientAPI, buffer as TSQLInfoResultsBuffer do |
1001 |
> |
with FFirebird30ClientAPI, buffer as TSQLInfoResultsBuffer do |
1002 |
|
begin |
1003 |
|
StatementIntf.getInfo(StatusIntf,1,BytePtr(@info_request), |
1004 |
|
GetBufSize, BytePtr(Buffer)); |
1014 |
|
IBError(ibxeEmptyQuery, [nil]); |
1015 |
|
try |
1016 |
|
CheckTransaction(FTransactionIntf); |
1017 |
< |
with Firebird30ClientAPI do |
1017 |
> |
with FFirebird30ClientAPI do |
1018 |
|
begin |
1019 |
|
if FHasParamNames then |
1020 |
|
begin |
1021 |
|
if FProcessedSQL = '' then |
1022 |
< |
FSQLParams.PreprocessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
1022 |
> |
ProcessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
1023 |
|
FStatementIntf := (GetAttachment as TFB30Attachment).AttachmentIntf.prepare(StatusIntf, |
1024 |
|
(FTransactionIntf as TFB30Transaction).TransactionIntf, |
1025 |
|
Length(FProcessedSQL), |
1026 |
< |
PChar(FProcessedSQL), |
1026 |
> |
PAnsiChar(FProcessedSQL), |
1027 |
|
FSQLDialect, |
1028 |
|
Firebird.IStatement.PREPARE_PREFETCH_METADATA); |
1029 |
|
end |
1031 |
|
FStatementIntf := (GetAttachment as TFB30Attachment).AttachmentIntf.prepare(StatusIntf, |
1032 |
|
(FTransactionIntf as TFB30Transaction).TransactionIntf, |
1033 |
|
Length(FSQL), |
1034 |
< |
PChar(FSQL), |
1034 |
> |
PAnsiChar(FSQL), |
1035 |
|
FSQLDialect, |
1036 |
|
Firebird.IStatement.PREPARE_PREFETCH_METADATA); |
1037 |
|
Check4DataBaseError; |
1111 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1112 |
|
|
1113 |
|
try |
1114 |
< |
with Firebird30ClientAPI do |
1114 |
> |
with FFirebird30ClientAPI do |
1115 |
|
begin |
1116 |
|
if FCollectStatistics then |
1117 |
|
begin |
1161 |
|
RemoveMonitor(aTransaction as TFB30Transaction); |
1162 |
|
end; |
1163 |
|
FExecTransactionIntf := aTransaction; |
1164 |
+ |
FSQLRecord.FTransaction := (aTransaction as TFB30Transaction); |
1165 |
+ |
FSQLRecord.FTransactionSeqNo := FSQLRecord.FTransaction.TransactionSeqNo; |
1166 |
|
SignalActivity; |
1167 |
|
Inc(FChangeSeqNo); |
1168 |
|
end; |
1182 |
|
if (FSQLParams.FTransactionSeqNo < (FTransactionIntf as TFB30transaction).TransactionSeqNo) then |
1183 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1184 |
|
|
1185 |
< |
with Firebird30ClientAPI do |
1185 |
> |
with FFirebird30ClientAPI do |
1186 |
|
begin |
1187 |
|
if FCollectStatistics then |
1188 |
|
begin |
1222 |
|
Inc(FChangeSeqNo); |
1223 |
|
end; |
1224 |
|
|
1225 |
+ |
procedure TFB30Statement.ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; |
1226 |
+ |
var processedSQL: AnsiString); |
1227 |
+ |
begin |
1228 |
+ |
FSQLParams.PreprocessSQL(sql,GenerateParamNames,processedSQL); |
1229 |
+ |
end; |
1230 |
+ |
|
1231 |
|
procedure TFB30Statement.FreeHandle; |
1232 |
|
begin |
1233 |
|
Close; |
1244 |
|
begin |
1245 |
|
if (FStatementIntf <> nil) and (SQLStatementType = SQLSelect) and FOpen then |
1246 |
|
try |
1247 |
< |
with Firebird30ClientAPI do |
1247 |
> |
with FFirebird30ClientAPI do |
1248 |
|
begin |
1249 |
|
if FResultSet <> nil then |
1250 |
|
begin |
1258 |
|
if not Force then Check4DataBaseError; |
1259 |
|
end; |
1260 |
|
finally |
1261 |
< |
if (FSQLRecord.FTransaction <> nil) and (FSQLRecord.FTransaction <> FTransactionIntf) then |
1261 |
> |
if (FSQLRecord.FTransaction <> nil) and (FSQLRecord.FTransaction <> (FTransactionIntf as TFB30Transaction)) then |
1262 |
|
RemoveMonitor(FSQLRecord.FTransaction); |
1263 |
|
FOpen := False; |
1264 |
|
FExecTransactionIntf := nil; |
1269 |
|
end; |
1270 |
|
|
1271 |
|
constructor TFB30Statement.Create(Attachment: TFB30Attachment; |
1272 |
< |
Transaction: ITransaction; sql: string; aSQLDialect: integer); |
1272 |
> |
Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer); |
1273 |
|
begin |
1274 |
|
inherited Create(Attachment,Transaction,sql,aSQLDialect); |
1275 |
+ |
FFirebird30ClientAPI := Attachment.Firebird30ClientAPI; |
1276 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1277 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1278 |
|
InternalPrepare; |
1279 |
|
end; |
1280 |
|
|
1281 |
|
constructor TFB30Statement.CreateWithParameterNames( |
1282 |
< |
Attachment: TFB30Attachment; Transaction: ITransaction; sql: string; |
1283 |
< |
aSQLDialect: integer; GenerateParamNames: boolean); |
1282 |
> |
Attachment: TFB30Attachment; Transaction: ITransaction; sql: AnsiString; |
1283 |
> |
aSQLDialect: integer; GenerateParamNames: boolean; |
1284 |
> |
CaseSensitiveParams: boolean); |
1285 |
|
begin |
1286 |
|
inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames); |
1287 |
+ |
FFirebird30ClientAPI := Attachment.Firebird30ClientAPI; |
1288 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1289 |
+ |
FSQLParams.CaseSensitiveParams := CaseSensitiveParams; |
1290 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1291 |
|
InternalPrepare; |
1292 |
|
end; |
1307 |
|
if FEOF then |
1308 |
|
IBError(ibxeEOF,[nil]); |
1309 |
|
|
1310 |
< |
with Firebird30ClientAPI do |
1310 |
> |
with FFirebird30ClientAPI do |
1311 |
|
begin |
1312 |
|
{ Go to the next record... } |
1313 |
|
fetchResult := FResultSet.fetchNext(StatusIntf,FSQLRecord.MessageBuffer); |
1332 |
|
FBOF := false; |
1333 |
|
result := true; |
1334 |
|
end; |
1335 |
+ |
if FCollectStatistics then |
1336 |
+ |
begin |
1337 |
+ |
UtilIntf.getPerfCounters(StatusIntf, |
1338 |
+ |
(GetAttachment as TFB30Attachment).AttachmentIntf, |
1339 |
+ |
ISQL_COUNTERS,@FAfterStats); |
1340 |
+ |
Check4DataBaseError; |
1341 |
+ |
FStatisticsAvailable := true; |
1342 |
+ |
end; |
1343 |
|
end; |
1344 |
|
FSQLRecord.RowChange; |
1345 |
|
SignalActivity; |
1363 |
|
Result := TMetaData(GetInterface(1)); |
1364 |
|
end; |
1365 |
|
|
1366 |
< |
function TFB30Statement.GetPlan: String; |
1366 |
> |
function TFB30Statement.GetPlan: AnsiString; |
1367 |
|
begin |
1368 |
|
CheckHandle; |
1369 |
|
if (not (FSQLStatementType in [SQLSelect, SQLSelectForUpdate, |
1371 |
|
SQLUpdate, SQLDelete])) then |
1372 |
|
result := '' |
1373 |
|
else |
1374 |
< |
with Firebird30ClientAPI do |
1374 |
> |
with FFirebird30ClientAPI do |
1375 |
|
begin |
1376 |
|
Result := FStatementIntf.getPlan(StatusIntf,true); |
1377 |
|
Check4DataBaseError; |