Firebird equivalent for resultset.last

Migrating from HSDBC to firebird, the above statement failed. I need to count the records in the resultset (oResult) retrieved by a SELECT statement, and formerly I used

oResult.last : nMax = oResult.row

There must be a simple equivalent, but I can’t find it. Help please?

Hello,

While there is no problem with this in Firebird server, items such as oResult.first() & oResult.last() are not being handled in Firebird embedded driver. Should be reported as a bug.

Suggestion. Run a separate query first (using same conditions) with Count(x). Result set will provide number of records.

FYI - Setting parameters in a prepared statement doesn’t work either.

Edit 2018-12-11:

Have run across this → Comment #2 in Bug #118094 and after limited testing appears to work in both Firebird server & Firebird embedded. Tests included First, Last, previous(), Row, RowCount, updateString(x, "xxx") and updateRow(). Again note there was limited testing done.

Also, the code worked from the IDE but modified:

oRS.DataSourceName = ThisComponent.Location

to:

oRS.DataSourceName = ThisComponent.Parent.Location

for it to work from a form.

Thanks, Ratslinger, very quick and helpful as usual. I actually solved it by restructuring the loop and stepping through the ResultSet (While oResult.next). Awkward code, but it worked.

That was a second choice.

Dear @Ratslinger ,

Will such second choice take a lot of time for a huge database ?

@Lonk,

If you are simply looking for a total count (as the case of the OP) then running the query as I mention in the answer is the quickest manner.