Subject Re: [firebird-support] IF condition
Author Helen Borrie
At 07:54 PM 4/04/2007, you wrote:
>Hi! In an IF condition is it possible to use a SELECT? Like this one:
>
>
> IF (SELECT COUNT(*) FROM TEMP WHERE (FLAG = 1) > 0) THEN
>BEGIN
>...
> END
>
> I did it this other way:
>
> SELECT COUNT(*) FROM TEMP WHERE FLAG = 1 INTO :MAS30;
> IF MAS30>0 THEN
> BEGIN
> END
>
> But just to know..
>
> In InterBase 7.5 I'm getting an error if I use the SELECT in the condition

Use EXISTS:

IF (EXISTS (SELECT 1 FROM TEMP WHERE FLAG = 1)) THEN
BEGIN
...
END

But, FYI, in PSQL, SELECT statements that return output always have
to return it into variables.

./hb