Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Relational Databases
Expertise: Beginner
Jul 14, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Displaying a Record Number for a Table

I use an InterBase database with an alias made in BDE. I want to display the record number for a table when I navigate through the records.

Your solution <>.RecNo always returns –1 because it is a TDataSet.RecNo.

Is there another solution?

There is no such thing as a record number with server-based databases such as InterBase and others like SQL Server and Oracle. This is because these database servers are set-based, not record-based. RecNo only applies to desktop databases like Paradox and dBASE (and clones).

You might be able to "fake" the record number with your table if you have a unique identifier in that table, and that unique identifier is a single column. In that case, you'd do something like this:

SELECT Count(UniqueIDColumn)
FROM MyTable
WHERE UniqueIDColumn <= IDValue
where IDValue is the ID value of the current "record." Of course, you'd have to know that with some sort of retrieval SQL statement.
DevX Pro
Thanks for your registration, follow us on our social networks to keep up-to-date