121 |
|
TIBXSQLVAR = class(TSQLVarData) |
122 |
|
private |
123 |
|
FStatement: TFB25Statement; |
124 |
+ |
FFirebird25ClientAPI: TFB25ClientAPI; |
125 |
|
FBlob: IBlob; {Cache references} |
126 |
|
FArray: IArray; |
127 |
|
FNullIndicator: short; |
178 |
|
function GetXSQLDA: PXSQLDA; |
179 |
|
protected |
180 |
|
FStatement: TFB25Statement; |
181 |
+ |
FFirebird25ClientAPI: TFB25ClientAPI; |
182 |
|
function GetTransactionSeqNo: integer; override; |
183 |
|
procedure FreeXSQLDA; |
184 |
|
function GetStatement: IStatement; override; |
243 |
|
private |
244 |
|
FDBHandle: TISC_DB_HANDLE; |
245 |
|
FHandle: TISC_STMT_HANDLE; |
246 |
+ |
FFirebird25ClientAPI: TFB25ClientAPI; |
247 |
|
FSQLParams: TIBXINPUTSQLDA; |
248 |
|
FSQLRecord: TIBXOUTPUTSQLDA; |
249 |
|
FCursor: AnsiString; { Cursor name...} |
255 |
|
procedure InternalPrepare; override; |
256 |
|
function InternalExecute(aTransaction: ITransaction): IResults; override; |
257 |
|
function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override; |
258 |
+ |
procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override; |
259 |
|
procedure FreeHandle; override; |
260 |
|
procedure InternalClose(Force: boolean); override; |
261 |
|
public |
445 |
|
begin |
446 |
|
inherited Initialize; |
447 |
|
FOwnsSQLData := true; |
448 |
< |
with FirebirdClientAPI, FXSQLVar^ do |
448 |
> |
with FFirebird25ClientAPI, FXSQLVar^ do |
449 |
|
begin |
450 |
|
case sqltype and (not 1) of |
451 |
|
SQL_TEXT, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TIMESTAMP, |
530 |
|
if not FOwnsSQLData then |
531 |
|
FXSQLVAR^.sqldata := nil; |
532 |
|
FXSQLVAR^.sqllen := len; |
533 |
< |
with FirebirdClientAPI do |
533 |
> |
with FFirebird25ClientAPI do |
534 |
|
IBAlloc(FXSQLVAR^.sqldata, 0, FXSQLVAR^.sqllen); |
535 |
|
FOwnsSQLData := true; |
536 |
|
Changed; |
562 |
|
begin |
563 |
|
inherited Create(aParent,aIndex); |
564 |
|
FStatement := aParent.Statement; |
565 |
+ |
FFirebird25ClientAPI := aParent.FFirebird25ClientAPI; |
566 |
|
end; |
567 |
|
|
568 |
|
procedure TIBXSQLVAR.FreeSQLData; |
633 |
|
begin |
634 |
|
if Count = 0 then |
635 |
|
Count := 1; |
636 |
< |
with Firebird25ClientAPI do |
636 |
> |
with FFirebird25ClientAPI do |
637 |
|
begin |
638 |
|
if (FXSQLDA <> nil) then |
639 |
|
if isc_dsql_describe_bind(StatusVector, @(FStatement.Handle), FStatement.SQLDialect, |
665 |
|
begin |
666 |
|
{ Allocate an initial output descriptor (with one column) } |
667 |
|
Count := 1; |
668 |
< |
with Firebird25ClientAPI do |
668 |
> |
with FFirebird25ClientAPI do |
669 |
|
begin |
670 |
|
{ Using isc_dsql_describe, get the right size for the columns... } |
671 |
|
if isc_dsql_describe(StatusVector, @(FStatement.Handle), FStatement.SQLDialect, FXSQLDA) > 0 then |
700 |
|
len := sqllen; |
701 |
|
if not IsNull and ((sqltype and (not 1)) = SQL_VARYING) then |
702 |
|
begin |
703 |
< |
with FirebirdClientAPI do |
703 |
> |
with FFirebird25ClientAPI do |
704 |
|
len := DecodeInteger(data,2); |
705 |
|
Inc(data,2); |
706 |
|
end; |
717 |
|
begin |
718 |
|
inherited Create; |
719 |
|
FStatement := aStatement; |
720 |
+ |
FFirebird25ClientAPI := aStatement.FFirebird25ClientAPI; |
721 |
|
FSize := 0; |
722 |
|
// writeln('Creating ',ClassName); |
723 |
|
end; |
804 |
|
OldSize := 0; |
805 |
|
if Count > FSize then |
806 |
|
begin |
807 |
< |
Firebird25ClientAPI.IBAlloc(FXSQLDA, OldSize, XSQLDA_LENGTH(Count)); |
807 |
> |
FFirebird25ClientAPI.IBAlloc(FXSQLDA, OldSize, XSQLDA_LENGTH(Count)); |
808 |
|
SetLength(FColumnList, FCount); |
809 |
|
FXSQLDA^.version := SQLDA_VERSION1; |
810 |
|
p := @FXSQLDA^.sqlvar[0]; |
902 |
|
procedure TFB25Statement.GetDsqlInfo(info_request: byte; buffer: ISQLInfoResults |
903 |
|
); |
904 |
|
begin |
905 |
< |
with Firebird25ClientAPI, buffer as TSQLInfoResultsBuffer do |
905 |
> |
with FFirebird25ClientAPI, buffer as TSQLInfoResultsBuffer do |
906 |
|
if isc_dsql_sql_info(StatusVector, @(FHandle), 1, @info_request, |
907 |
|
GetBufSize, Buffer) > 0 then |
908 |
|
IBDatabaseError; |
919 |
|
IBError(ibxeEmptyQuery, [nil]); |
920 |
|
try |
921 |
|
CheckTransaction(FTransactionIntf); |
922 |
< |
with Firebird25ClientAPI do |
922 |
> |
with FFirebird25ClientAPI do |
923 |
|
begin |
924 |
|
Call(isc_dsql_alloc_statement2(StatusVector, @(FDBHandle), |
925 |
|
@FHandle), True); |
927 |
|
if FHasParamNames then |
928 |
|
begin |
929 |
|
if FProcessedSQL = '' then |
930 |
< |
FSQLParams.PreprocessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
930 |
> |
ProcessSQL(FSQL,FGenerateParamNames,FProcessedSQL); |
931 |
|
Call(isc_dsql_prepare(StatusVector, @(TRHandle), @FHandle, 0, |
932 |
|
PAnsiChar(FProcessedSQL), FSQLDialect, nil), True); |
933 |
|
end |
1013 |
|
|
1014 |
|
try |
1015 |
|
TRHandle := (aTransaction as TFB25Transaction).Handle; |
1016 |
< |
with Firebird25ClientAPI do |
1016 |
> |
with FFirebird25ClientAPI do |
1017 |
|
begin |
1018 |
|
if FCollectStatistics then |
1019 |
|
GetPerfCounters(FBeforeStats); |
1074 |
|
if (FSQLParams.FTransactionSeqNo < (FTransactionIntf as TFB25transaction).TransactionSeqNo) then |
1075 |
|
IBError(ibxeInterfaceOutofDate,[nil]); |
1076 |
|
|
1077 |
< |
with Firebird25ClientAPI do |
1077 |
> |
with FFirebird25ClientAPI do |
1078 |
|
begin |
1079 |
|
if FCollectStatistics then |
1080 |
|
GetPerfCounters(FBeforeStats); |
1113 |
|
Inc(FChangeSeqNo); |
1114 |
|
end; |
1115 |
|
|
1116 |
+ |
procedure TFB25Statement.ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; |
1117 |
+ |
var processedSQL: AnsiString); |
1118 |
+ |
begin |
1119 |
+ |
FSQLParams.PreprocessSQL(sql,GenerateParamNames, processedSQL); |
1120 |
+ |
end; |
1121 |
+ |
|
1122 |
|
procedure TFB25Statement.FreeHandle; |
1123 |
|
var |
1124 |
|
isc_res: ISC_STATUS; |
1127 |
|
ReleaseInterfaces; |
1128 |
|
try |
1129 |
|
if FHandle <> nil then |
1130 |
< |
with Firebird25ClientAPI do |
1130 |
> |
with FFirebird25ClientAPI do |
1131 |
|
begin |
1132 |
|
isc_res := |
1133 |
|
Call(isc_dsql_free_statement(StatusVector, @FHandle, DSQL_drop), False); |
1147 |
|
begin |
1148 |
|
if (FHandle <> nil) and (SQLStatementType = SQLSelect) and FOpen then |
1149 |
|
try |
1150 |
< |
with Firebird25ClientAPI do |
1150 |
> |
with FFirebird25ClientAPI do |
1151 |
|
begin |
1152 |
|
isc_res := Call( |
1153 |
|
isc_dsql_free_statement(StatusVector, @FHandle, DSQL_close), |
1172 |
|
begin |
1173 |
|
inherited Create(Attachment,Transaction,sql,aSQLDialect); |
1174 |
|
FDBHandle := Attachment.Handle; |
1175 |
+ |
FFirebird25ClientAPI := Attachment.Firebird25ClientAPI; |
1176 |
+ |
OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError; |
1177 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1178 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1179 |
|
InternalPrepare; |
1185 |
|
begin |
1186 |
|
inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames); |
1187 |
|
FDBHandle := Attachment.Handle; |
1188 |
+ |
FFirebird25ClientAPI := Attachment.Firebird25ClientAPI; |
1189 |
+ |
OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError; |
1190 |
|
FSQLParams := TIBXINPUTSQLDA.Create(self); |
1191 |
|
FSQLRecord := TIBXOUTPUTSQLDA.Create(self); |
1192 |
|
InternalPrepare; |
1209 |
|
if FEOF then |
1210 |
|
IBError(ibxeEOF,[nil]); |
1211 |
|
|
1212 |
< |
with Firebird25ClientAPI do |
1212 |
> |
with FFirebird25ClientAPI do |
1213 |
|
begin |
1214 |
|
{ Go to the next record... } |
1215 |
|
fetch_res := |
1272 |
|
result := '' |
1273 |
|
else |
1274 |
|
begin |
1275 |
< |
RB := TSQLInfoResultsBuffer.Create(4*4096); |
1275 |
> |
RB := TSQLInfoResultsBuffer.Create(FFirebird25ClientAPI,4*4096); |
1276 |
|
GetDsqlInfo(isc_info_sql_get_plan,RB); |
1277 |
|
if RB.Count > 0 then |
1278 |
|
Result := RB[0].GetAsString; |