Ask Your Question

firebird equivalent for resultset.last

asked 2018-11-06 18:07:58 +0100

Pansmanser gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-11-06 19:01:55 +0100

Ratslinger gravatar image

updated 2018-12-11 18:15:05 +0100


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


oRS.DataSourceName = ThisComponent.Parent.Location

for it to work from a form.

edit flag offensive delete link more


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

Pansmanser gravatar imagePansmanser ( 2018-11-06 19:13:53 +0100 )edit

That was a second choice.

Ratslinger gravatar imageRatslinger ( 2018-11-06 19:34:03 +0100 )edit

Dear @Ratslinger ,

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

lonk gravatar imagelonk ( 2019-11-27 10:17:37 +0100 )edit


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.

Ratslinger gravatar imageRatslinger ( 2019-11-27 21:15:32 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-11-06 18:07:58 +0100

Seen: 236 times

Last updated: Dec 11 '18