Subject | Re: [ib-support] is table empty? |
---|---|
Author | Christian Gütter |
Post date | 2003-05-12T15:59:45Z |
Hi Fred,
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
> Is there a more elegant way to determineIn PSQL:
> if a table is empty in Firebird?
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