Subject Re: [ib-support] is table empty?
Author Marco Lauria
At 10.43 12/05/2003 -0500, you wrote:
>I am converting a database from Informix to Firebird. So far, I have found
>Firebird to be quite up to the task and am very impressed with its maturity,
>performance, and reliability. I do have a question: Informix keeps row
>count information in its table control structures so "select count(*) from
>table" is instantaneous even if the table contains a billion rows. It
>appears that Firebird actually counts the rows. In my app this query is
>often used to determined if a table is empty, so I suppose I could write a
>stored procedure that opens a cursor, does a fetch, and returns a yes/no for
>table "emptiness". Is there a more elegant way to determine if a table is
>empty in Firebird?

Hi!

Use:
EXISTS( SELECT * FROM TABLE)
in the where clause
exists return true immediately if it can fetch a row from the select else
it will returns false.
Regards
Marco