Subject Re: [IBO] Trouble with Count(*)
Author Helen Borrie
At 10:05 AM 14/04/2004 -0400, you wrote:
>Hi,
>
>I am a bit of a neophyte with SQL ...
>
>I am trying to get the count for a number of records matching certain
>criteria.
>
>I looked in the LANGREF.PDF that comes with and the syntax shows either:
>
>SELECT COUNT(*) INTO :field FROM TABLE WHERE condition;

ESQL syntax - not applicable to DSQL (dynamic SQL - the one we use)

I won't go into the details of your code (it's a bit of a minefield).

If you *must* count records (why?????) do it with a TIB_DSQL.

The statement you want is
SELECT COUNT(*) FROM ATABLE as NumberOfRows
WHERE <WHATEVER>

Assign the SQL to the TIB_DSQL, Prepare, Execute; then read
Fields[0].AsInteger or Field['NumberOfRows'].AsInteger

Helen