ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/client/2.5/FB25Statement.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/2.5/FB25Statement.pas (file contents):
Revision 262 by tony, Wed Mar 14 12:48:51 2018 UTC vs.
Revision 263 by tony, Thu Dec 6 15:55:01 2018 UTC

# Line 121 | Line 121 | type
121    TIBXSQLVAR = class(TSQLVarData)
122    private
123      FStatement: TFB25Statement;
124 +    FFirebird25ClientAPI: TFB25ClientAPI;
125      FBlob: IBlob;             {Cache references}
126      FArray: IArray;
127      FNullIndicator: short;
# Line 177 | Line 178 | type
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;
# Line 241 | Line 243 | type
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...}
# Line 252 | Line 255 | type
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
# Line 441 | Line 445 | procedure TIBXSQLVAR.Initialize;
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,
# Line 526 | Line 530 | begin
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;
# Line 558 | Line 562 | constructor TIBXSQLVAR.Create(aParent: T
562   begin
563    inherited Create(aParent,aIndex);
564    FStatement := aParent.Statement;
565 +  FFirebird25ClientAPI := aParent.FFirebird25ClientAPI;
566   end;
567  
568   procedure TIBXSQLVAR.FreeSQLData;
# Line 628 | Line 633 | procedure TIBXINPUTSQLDA.Bind;
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,
# Line 660 | Line 665 | procedure TIBXOUTPUTSQLDA.Bind;
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
# Line 695 | Line 700 | begin
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;
# Line 712 | Line 717 | constructor TIBXSQLDA.Create(aStatement:
717   begin
718    inherited Create;
719    FStatement := aStatement;
720 +  FFirebird25ClientAPI := aStatement.FFirebird25ClientAPI;
721    FSize := 0;
722   //  writeln('Creating ',ClassName);
723   end;
# Line 798 | Line 804 | begin
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];
# Line 896 | Line 902 | end;
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;
# Line 913 | Line 919 | begin
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);
# Line 921 | Line 927 | begin
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
# Line 1007 | Line 1013 | begin
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);
# Line 1068 | Line 1074 | begin
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);
# Line 1107 | Line 1113 | begin
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;
# Line 1115 | Line 1127 | begin
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);
# Line 1135 | Line 1147 | var
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),
# Line 1160 | Line 1172 | constructor TFB25Statement.Create(Attach
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;
# Line 1171 | Line 1185 | constructor TFB25Statement.CreateWithPar
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;
# Line 1193 | Line 1209 | begin
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 :=
# Line 1256 | Line 1272 | begin
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines