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 349 by tony, Mon Oct 18 08:39:40 2021 UTC vs.
Revision 350 by tony, Wed Oct 20 14:58:56 2021 UTC

# Line 236 | Line 236 | type
236      constructor Create(aResults: TIBXOUTPUTSQLDA);
237      destructor Destroy; override;
238      {IResultSet}
239 <    function FetchNext: boolean;
239 >    function FetchNext: boolean; {fetch next record}
240 >    function FetchPrior: boolean; {fetch previous record}
241 >    function FetchFirst:boolean; {fetch first record}
242 >    function FetchLast: boolean; {fetch last record}
243 >    function FetchAbsolute(position: Integer): boolean; {fetch record by its absolute position in result set}
244 >    function FetchRelative(offset: Integer): boolean; {fetch record by position relative to current}
245      function GetCursorName: AnsiString;
246      function GetTransaction: ITransaction; override;
247      function IsEof: boolean;
248 +    function IsBof: boolean;
249      procedure Close;
250    end;
251  
# Line 258 | Line 264 | type
264    protected
265      procedure CheckHandle; override;
266      procedure GetDsqlInfo(info_request: byte; buffer: ISQLInfoResults); override;
267 <    procedure InternalPrepare; override;
267 >    procedure InternalPrepare(CursorName: AnsiString=''); override;
268      function InternalExecute(aTransaction: ITransaction): IResults; override;
269 <    function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override;
269 >    function InternalOpenCursor(aTransaction: ITransaction; Scrollable: boolean): IResultSet; override;
270      procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override;
271      procedure FreeHandle; override;
272      procedure InternalClose(Force: boolean); override;
273    public
274      constructor Create(Attachment: TFB25Attachment; Transaction: ITransaction;
275 <      sql: AnsiString; aSQLDialect: integer);
275 >      sql: AnsiString; aSQLDialect: integer; CursorName: AnsiString='');
276      constructor CreateWithParameterNames(Attachment: TFB25Attachment;
277        Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean;
278 <      CaseSensitiveParams: boolean=false);
278 >      CaseSensitiveParams: boolean=false; CursorName: AnsiString='');
279      destructor Destroy; override;
280      function FetchNext: boolean;
281  
# Line 637 | Line 643 | begin
643        FResults.Column[i].RowChange;
644   end;
645  
646 + function TResultSet.FetchPrior: boolean;
647 + begin
648 +  IBError(ibxeNoScrollableCursors,[]);
649 + end;
650 +
651 + function TResultSet.FetchFirst: boolean;
652 + begin
653 +  IBError(ibxeNoScrollableCursors,[]);
654 + end;
655 +
656 + function TResultSet.FetchLast: boolean;
657 + begin
658 +  IBError(ibxeNoScrollableCursors,[]);
659 + end;
660 +
661 + function TResultSet.FetchAbsolute(position: Integer): boolean;
662 + begin
663 +  IBError(ibxeNoScrollableCursors,[]);
664 + end;
665 +
666 + function TResultSet.FetchRelative(offset: Integer): boolean;
667 + begin
668 +  IBError(ibxeNoScrollableCursors,[]);
669 + end;
670 +
671   function TResultSet.GetCursorName: AnsiString;
672   begin
673    Result := FResults.FStatement.FCursor;
# Line 652 | Line 683 | begin
683    Result := FResults.FStatement.FEof;
684   end;
685  
686 + function TResultSet.IsBof: boolean;
687 + begin
688 +  Result := FResults.FStatement.FBof;
689 + end;
690 +
691   procedure TResultSet.Close;
692   begin
693    if FCursorSeqNo = FResults.FStatement.FCursorSeqNo then
# Line 939 | Line 975 | begin
975      IBDatabaseError;
976   end;
977  
978 < procedure TFB25Statement.InternalPrepare;
978 > procedure TFB25Statement.InternalPrepare(CursorName: AnsiString);
979   var
980 +  GUID: TGUID;
981    RB: ISQLInfoResults;
982    TRHandle: TISC_TR_HANDLE;
983   begin
984    if FPrepared then
985      Exit;
986 +
987    if (FSQL = '') then
988      IBError(ibxeEmptyQuery, [nil]);
989 +
990 +  FCursor := CursorName;
991 +  if FCursor = '' then
992 +  begin
993 +    CreateGuid(GUID);
994 +    FCursor := GUIDToString(GUID);
995 +  end;
996 +
997    try
998      CheckTransaction(FTransactionIntf);
999      with FFirebird25ClientAPI do
# Line 966 | Line 1012 | begin
1012          Call(isc_dsql_prepare(StatusVector, @(TRHandle), @FHandle, 0,
1013                   PAnsiChar(FSQL), FSQLDialect, nil), True);
1014      end;
1015 +
1016      { After preparing the statement, query the stmt type and possibly
1017        create a FSQLRecord "holder" }
1018      { Get the type of the statement }
# Line 975 | Line 1022 | begin
1022      else
1023        FSQLStatementType := SQLUnknown;
1024  
1025 +    if FSQLStatementType = SQLSelect then
1026 +    with FFirebird25ClientAPI do
1027 +      Call(
1028 +        isc_dsql_set_cursor_name(StatusVector, @FHandle, PAnsiChar(FCursor), 0),
1029 +        True);
1030 +
1031      case FSQLStatementType of
1032        SQLGetSegment,
1033        SQLPutSegment,
# Line 1084 | Line 1137 | begin
1137    Inc(FChangeSeqNo);
1138   end;
1139  
1140 < function TFB25Statement.InternalOpenCursor(aTransaction: ITransaction
1141 <  ): IResultSet;
1140 > function TFB25Statement.InternalOpenCursor(aTransaction: ITransaction;
1141 >  Scrollable: boolean): IResultSet;
1142   var TRHandle: TISC_TR_HANDLE;
1090    GUID : TGUID;
1143   begin
1144    if FSQLStatementType <> SQLSelect then
1145     IBError(ibxeIsASelectStatement,[]);
1146  
1147 +  if Scrollable then
1148 +    IBError(ibxeNoScrollableCursors,[]);
1149 +
1150   CheckTransaction(aTransaction);
1151    if not FPrepared then
1152      InternalPrepare;
# Line 1113 | Line 1168 | begin
1168                         SQLDialect,
1169                         FSQLParams.AsXSQLDA,
1170                         nil), True);
1116   if FCursor = '' then
1117   begin
1118     CreateGuid(GUID);
1119     FCursor := GUIDToString(GUID);
1120     Call(
1121       isc_dsql_set_cursor_name(StatusVector, @FHandle, PAnsiChar(FCursor), 0),
1122       True);
1123   end;
1171  
1172     if FCollectStatistics then
1173     begin
# Line 1195 | Line 1242 | begin
1242   end;
1243  
1244   constructor TFB25Statement.Create(Attachment: TFB25Attachment;
1245 <  Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer);
1245 >  Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1246 >  CursorName: AnsiString);
1247   begin
1248    inherited Create(Attachment,Transaction,sql,aSQLDialect);
1249    FDBHandle := Attachment.Handle;
# Line 1203 | Line 1251 | begin
1251    OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError;
1252    FSQLParams := TIBXINPUTSQLDA.Create(self);
1253    FSQLRecord := TIBXOUTPUTSQLDA.Create(self);
1254 <  InternalPrepare;
1254 >  InternalPrepare(CursorName);
1255   end;
1256  
1257   constructor TFB25Statement.CreateWithParameterNames(
1258    Attachment: TFB25Attachment; Transaction: ITransaction; sql: AnsiString;
1259    aSQLDialect: integer; GenerateParamNames: boolean;
1260 <  CaseSensitiveParams: boolean);
1260 >  CaseSensitiveParams: boolean; CursorName: AnsiString);
1261   begin
1262    inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames);
1263    FDBHandle := Attachment.Handle;
# Line 1218 | Line 1266 | begin
1266    FSQLParams := TIBXINPUTSQLDA.Create(self);
1267    FSQLParams.CaseSensitiveParams := CaseSensitiveParams;
1268    FSQLRecord := TIBXOUTPUTSQLDA.Create(self);
1269 <  InternalPrepare;
1269 >  InternalPrepare(CursorName);
1270   end;
1271  
1272   destructor TFB25Statement.Destroy;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines