87 |
|
TIBXSQLVAR = class(TSQLVarData) |
88 |
|
private |
89 |
|
FStatement: TFB30Statement; |
90 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
91 |
|
FBlob: IBlob; {Cache references} |
92 |
|
FArray: IArray; |
93 |
|
FNullIndicator: short; |
101 |
|
FSQLData: PByte; {Address of SQL Data in Message Buffer} |
102 |
|
FSQLNullIndicator: PShort; {Address of null indicator} |
103 |
|
FDataLength: integer; |
104 |
+ |
FMetadataSize: integer; |
105 |
|
FNullable: boolean; |
106 |
|
FScale: integer; |
107 |
|
FCharSetID: cardinal; |
118 |
|
function GetScale: integer; override; |
119 |
|
function GetCharSetID: cardinal; override; |
120 |
|
function GetCodePage: TSystemCodePage; override; |
121 |
+ |
function GetCharSetWidth: integer; override; |
122 |
|
function GetIsNull: Boolean; override; |
123 |
|
function GetIsNullable: boolean; override; |
124 |
|
function GetSQLData: PByte; override; |
125 |
|
function GetDataLength: cardinal; override; |
126 |
+ |
function GetSize: cardinal; override; |
127 |
|
procedure SetIsNull(Value: Boolean); override; |
128 |
|
procedure SetIsNullable(Value: Boolean); override; |
129 |
|
procedure SetSQLData(AValue: PByte; len: cardinal); override; |
152 |
|
FSize: Integer; {Number of TIBXSQLVARs in column list} |
153 |
|
FMetaData: Firebird.IMessageMetadata; |
154 |
|
FTransactionSeqNo: integer; |
155 |
< |
protected |
155 |
> |
protected |
156 |
|
FStatement: TFB30Statement; |
157 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
158 |
|
function GetTransactionSeqNo: integer; override; |
159 |
|
procedure FreeXSQLDA; virtual; |
160 |
|
function GetStatement: IStatement; override; |
241 |
|
TFB30Statement = class(TFBStatement,IStatement) |
242 |
|
private |
243 |
|
FStatementIntf: Firebird.IStatement; |
244 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
245 |
|
FSQLParams: TIBXINPUTSQLDA; |
246 |
|
FSQLRecord: TIBXOUTPUTSQLDA; |
247 |
|
FResultSet: Firebird.IResultSet; |
252 |
|
procedure InternalPrepare; override; |
253 |
|
function InternalExecute(aTransaction: ITransaction): IResults; override; |
254 |
|
function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override; |
255 |
+ |
procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override; |
256 |
|
procedure FreeHandle; override; |
257 |
|
procedure InternalClose(Force: boolean); override; |
258 |
|
public |
259 |
|
constructor Create(Attachment: TFB30Attachment; Transaction: ITransaction; |
260 |
|
sql: AnsiString; aSQLDialect: integer); |
261 |
|
constructor CreateWithParameterNames(Attachment: TFB30Attachment; Transaction: ITransaction; |
262 |
< |
sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean =false); |
262 |
> |
sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean =false; |
263 |
> |
CaseSensitiveParams: boolean=false); |
264 |
|
destructor Destroy; override; |
265 |
|
function FetchNext: boolean; |
266 |
|
property StatementIntf: Firebird.IStatement read FStatementIntf; |
304 |
|
|
305 |
|
function TIBXSQLVAR.GetAliasName: AnsiString; |
306 |
|
begin |
307 |
< |
with Firebird30ClientAPI do |
307 |
> |
with FFirebird30ClientAPI do |
308 |
|
begin |
309 |
|
result := strpas(TIBXSQLDA(Parent).MetaData.getAlias(StatusIntf,Index)); |
310 |
|
Check4DataBaseError; |
318 |
|
|
319 |
|
function TIBXSQLVAR.GetOwnerName: AnsiString; |
320 |
|
begin |
321 |
< |
with Firebird30ClientAPI do |
321 |
> |
with FFirebird30ClientAPI do |
322 |
|
begin |
323 |
|
result := strpas(TIBXSQLDA(Parent).MetaData.getOwner(StatusIntf,Index)); |
324 |
|
Check4DataBaseError; |
362 |
|
CharSetID2CodePage(GetCharSetID,result); |
363 |
|
end; |
364 |
|
|
365 |
+ |
function TIBXSQLVAR.GetCharSetWidth: integer; |
366 |
+ |
begin |
367 |
+ |
result := 1; |
368 |
+ |
with Statement.GetAttachment DO |
369 |
+ |
CharSetWidth(GetCharSetID,result); |
370 |
+ |
end; |
371 |
+ |
|
372 |
|
function TIBXSQLVAR.GetIsNull: Boolean; |
373 |
|
begin |
374 |
|
Result := IsNullable and (FSQLNullIndicator^ = -1); |
389 |
|
Result := FDataLength; |
390 |
|
end; |
391 |
|
|
392 |
+ |
function TIBXSQLVAR.GetSize: cardinal; |
393 |
+ |
begin |
394 |
+ |
Result := FMetadataSize; |
395 |
+ |
end; |
396 |
+ |
|
397 |
|
function TIBXSQLVAR.GetArrayMetaData: IArrayMetaData; |
398 |
|
begin |
399 |
|
if GetSQLType <> SQL_ARRAY then |
467 |
|
if not FOwnsSQLData then |
468 |
|
FSQLData := nil; |
469 |
|
FDataLength := len; |
470 |
< |
with Firebird30ClientAPI do |
470 |
> |
with FFirebird30ClientAPI do |
471 |
|
IBAlloc(FSQLData, 0, FDataLength); |
472 |
|
FOwnsSQLData := true; |
473 |
|
Changed; |
489 |
|
begin |
490 |
|
inherited Create(aParent,aIndex); |
491 |
|
FStatement := aParent.Statement; |
492 |
+ |
FFirebird30ClientAPI := aParent.FFirebird30ClientAPI; |
493 |
|
end; |
494 |
|
|
495 |
|
procedure TIBXSQLVAR.RowChange; |
650 |
|
i: integer; |
651 |
|
begin |
652 |
|
if FCurMetaData = nil then |
653 |
< |
with Firebird30ClientAPI do |
653 |
> |
with FFirebird30ClientAPI do |
654 |
|
begin |
655 |
|
Builder := inherited MetaData.getBuilder(StatusIntf); |
656 |
|
Check4DataBaseError; |
683 |
|
BuildMetadata; |
684 |
|
|
685 |
|
if FMsgLength = 0 then |
686 |
< |
with Firebird30ClientAPI do |
686 |
> |
with FFirebird30ClientAPI do |
687 |
|
begin |
688 |
|
FMsgLength := FCurMetaData.getMessageLength(StatusIntf); |
689 |
|
Check4DataBaseError; |
733 |
|
var i: integer; |
734 |
|
begin |
735 |
|
FMetaData := aMetaData; |
736 |
< |
with Firebird30ClientAPI do |
736 |
> |
with FFirebird30ClientAPI do |
737 |
|
begin |
738 |
|
Count := metadata.getCount(StatusIntf); |
739 |
|
Check4DataBaseError; |
752 |
|
else |
753 |
|
FSQLSubType := 0; |
754 |
|
FDataLength := aMetaData.getLength(StatusIntf,i); |
755 |
+ |
FMetadataSize := FDataLength; |
756 |
|
Check4DataBaseError; |
757 |
|
case SQLType of |
758 |
|
SQL_TEXT, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TIMESTAMP, |
759 |
|
SQL_BLOB, SQL_ARRAY, SQL_QUAD, SQL_SHORT, SQL_BOOLEAN, |
760 |
< |
SQL_LONG, SQL_INT64, SQL_DOUBLE, SQL_FLOAT, SQL_D_FLOAT: |
760 |
> |
SQL_LONG, SQL_INT64, SQL_INT128, SQL_DOUBLE, SQL_FLOAT, SQL_D_FLOAT, |
761 |
> |
SQL_TIMESTAMP_TZ, SQL_TIME_TZ, SQL_DEC_FIXED, SQL_DEC16, SQL_DEC34, |
762 |
> |
SQL_TIMESTAMP_TZ_EX, SQL_TIME_TZ_EX: |
763 |
|
begin |
764 |
|
if (FDataLength = 0) then |
765 |
|
{ Make sure you get a valid pointer anyway |
814 |
|
var i: integer; |
815 |
|
begin |
816 |
|
FMetaData := aMetaData; |
817 |
< |
with Firebird30ClientAPI do |
817 |
> |
with FFirebird30ClientAPI do |
818 |
|
begin |
819 |
|
Count := metadata.getCount(StatusIntf); |
820 |
|
Check4DataBaseError; |
842 |
|
Check4DataBaseError; |
843 |
|
FDataLength := aMetaData.getLength(StatusIntf,i); |
844 |
|
Check4DataBaseError; |
845 |
+ |
FMetadataSize := FDataLength; |
846 |
|
FRelationName := strpas(aMetaData.getRelation(StatusIntf,i)); |
847 |
|
Check4DataBaseError; |
848 |
|
FFieldName := strpas(aMetaData.getField(StatusIntf,i)); |
875 |
|
len := FDataLength; |
876 |
|
if not IsNull and (FSQLType = SQL_VARYING) then |
877 |
|
begin |
878 |
< |
with Firebird30ClientAPI do |
878 |
> |
with FFirebird30ClientAPI do |
879 |
|
len := DecodeInteger(data,2); |
880 |
|
Inc(Data,2); |
881 |
|
end; |
892 |
|
begin |
893 |
|
inherited Create; |
894 |
|
FStatement := aStatement; |
895 |
+ |
FFirebird30ClientAPI := aStatement.FFirebird30ClientAPI; |
896 |
|
FSize := 0; |
897 |
|
// writeln('Creating ',ClassName); |
898 |
|
end; |
1009 |
|
procedure TFB30Statement.GetDSQLInfo(info_request: byte; buffer: ISQLInfoResults |
1010 |
|
); |
1011 |
|
begin |
1012 |
< |
with Firebird30ClientAPI, buffer as TSQLInfoResultsBuffer do |
1012 |
> |
with FFirebird30ClientAPI, buffer as TSQLInfoResultsBuffer do |
1013 |
|
begin |
1014 |
|
StatementIntf.getInfo(StatusIntf,1,BytePtr(@info_request), |
1015 |
|
GetBufSize, BytePtr(Buffer)); |
1025 |
|
IBError(ibxeEmptyQuery, [nil]); |
1026 |
|
try |
1027 |
|
CheckTransaction(FTransactionIntf); |
1028 |
< |
with Firebird30ClientAPI do |
1028 |
> |
with FFirebird30ClientAPI do |
1029 |
|
begin |
1030 |
|
if FHasParamNames then |
1031 |
|
begin |
1032 |
|
if FProcessedSQL = '' then |
1033 |
< |
FSQLParams.PreprocessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
1033 |
> |
ProcessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
1034 |
|
FStatementIntf := (GetAttachment as TFB30Attachment).AttachmentIntf.prepare(StatusIntf, |
1035 |
|
(FTransactionIntf as TFB30Transaction).TransactionIntf, |
1036 |
|
Length(FProcessedSQL), |
1081 |
|
if (FStatementIntf <> nil) then |
1082 |
|
FreeHandle; |
1083 |
|
if E is EIBInterBaseError then |
1084 |
< |
raise EIBInterBaseError.Create(EIBInterBaseError(E).SQLCode, |
1085 |
< |
EIBInterBaseError(E).IBErrorCode, |
1060 |
< |
EIBInterBaseError(E).Message + |
1061 |
< |
sSQLErrorSeparator + FSQL) |
1062 |
< |
else |
1063 |
< |
raise; |
1084 |
> |
E.Message := E.Message + sSQLErrorSeparator + FSQL; |
1085 |
> |
raise; |
1086 |
|
end; |
1087 |
|
end; |
1088 |
|
FPrepared := true; |
1118 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1119 |
|
|
1120 |
|
try |
1121 |
< |
with Firebird30ClientAPI do |
1121 |
> |
with FFirebird30ClientAPI do |
1122 |
|
begin |
1123 |
|
if FCollectStatistics then |
1124 |
|
begin |
1189 |
|
if (FSQLParams.FTransactionSeqNo < (FTransactionIntf as TFB30transaction).TransactionSeqNo) then |
1190 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1191 |
|
|
1192 |
< |
with Firebird30ClientAPI do |
1192 |
> |
with FFirebird30ClientAPI do |
1193 |
|
begin |
1194 |
|
if FCollectStatistics then |
1195 |
|
begin |
1229 |
|
Inc(FChangeSeqNo); |
1230 |
|
end; |
1231 |
|
|
1232 |
+ |
procedure TFB30Statement.ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; |
1233 |
+ |
var processedSQL: AnsiString); |
1234 |
+ |
begin |
1235 |
+ |
FSQLParams.PreprocessSQL(sql,GenerateParamNames,processedSQL); |
1236 |
+ |
end; |
1237 |
+ |
|
1238 |
|
procedure TFB30Statement.FreeHandle; |
1239 |
|
begin |
1240 |
|
Close; |
1251 |
|
begin |
1252 |
|
if (FStatementIntf <> nil) and (SQLStatementType = SQLSelect) and FOpen then |
1253 |
|
try |
1254 |
< |
with Firebird30ClientAPI do |
1254 |
> |
with FFirebird30ClientAPI do |
1255 |
|
begin |
1256 |
|
if FResultSet <> nil then |
1257 |
|
begin |
1279 |
|
Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer); |
1280 |
|
begin |
1281 |
|
inherited Create(Attachment,Transaction,sql,aSQLDialect); |
1282 |
+ |
FFirebird30ClientAPI := Attachment.Firebird30ClientAPI; |
1283 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1284 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1285 |
|
InternalPrepare; |
1287 |
|
|
1288 |
|
constructor TFB30Statement.CreateWithParameterNames( |
1289 |
|
Attachment: TFB30Attachment; Transaction: ITransaction; sql: AnsiString; |
1290 |
< |
aSQLDialect: integer; GenerateParamNames: boolean); |
1290 |
> |
aSQLDialect: integer; GenerateParamNames: boolean; |
1291 |
> |
CaseSensitiveParams: boolean); |
1292 |
|
begin |
1293 |
|
inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames); |
1294 |
+ |
FFirebird30ClientAPI := Attachment.Firebird30ClientAPI; |
1295 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1296 |
+ |
FSQLParams.CaseSensitiveParams := CaseSensitiveParams; |
1297 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1298 |
|
InternalPrepare; |
1299 |
|
end; |
1314 |
|
if FEOF then |
1315 |
|
IBError(ibxeEOF,[nil]); |
1316 |
|
|
1317 |
< |
with Firebird30ClientAPI do |
1317 |
> |
with FFirebird30ClientAPI do |
1318 |
|
begin |
1319 |
|
{ Go to the next record... } |
1320 |
|
fetchResult := FResultSet.fetchNext(StatusIntf,FSQLRecord.MessageBuffer); |
1378 |
|
SQLUpdate, SQLDelete])) then |
1379 |
|
result := '' |
1380 |
|
else |
1381 |
< |
with Firebird30ClientAPI do |
1381 |
> |
with FFirebird30ClientAPI do |
1382 |
|
begin |
1383 |
|
Result := FStatementIntf.getPlan(StatusIntf,true); |
1384 |
|
Check4DataBaseError; |