Subject | Re: Spam Alert: Re: [ib-support] How can I check if a table is empty? |
---|---|
Author | Helen Borrie |
Post date | 2003-05-07T02:18:53Z |
At 11:58 AM 7/05/2003 +1000, you wrote:
You can do the EXISTS() test in DSQL inside a WHERE clause, e.g.
SELECT.....
WHERE EXISTS(SELECT 1 FROM MyTable)
So to test whether MyTable is empty you could just create a bare DSQL
select statement that returns something, e.g
select '1' from rdb$database where exists(select 1 from MyTable)
heLen
>PODESTA Mariano APRE wrote:It's a PSQL construct so - by calling a stored procedure that uses it.
>
> > try
> >
> > if (exists (select * from MyTable)) then
> > ..
> >
> > this statement is fast and does not fetch all records.
>
>How would you use that in Delphi with IBX?
You can do the EXISTS() test in DSQL inside a WHERE clause, e.g.
SELECT.....
WHERE EXISTS(SELECT 1 FROM MyTable)
So to test whether MyTable is empty you could just create a bare DSQL
select statement that returns something, e.g
select '1' from rdb$database where exists(select 1 from MyTable)
heLen