Subject Re: [ib-support] is table empty?
Author Christian Gütter
Hi Fred,

> Is there a more elegant way to determine
> if a table is empty in Firebird?

In PSQL:
IF (EXISTS(SELECT * FROM MyTable)) THEN ...

In DSQL, you can use EXISTS in the WHERE clause:
SELECT '1' FROM RDB$Database WHERE EXISTS(SELECT 1 FROM MyTable)
If MyTable is empty, this statement returns NULL, otherwise
it returns '1'. And this is very fast.


HTH,

Christian