Subject Re: [ib-support] Re: SQL ORDER BY problem
Author Dimitry Sibiryakov
On 25 Jul 2002 at 10:47, csswa wrote:

>It walks the data until it finds a match (it needs only one), at which
>point the EXISTS condition becomes true so it exits to do the
>first-case select. If it walks the entire db without finding a first-
>case match then it does the second-case select. EXISTS is my
>favourite keyword :-)

I'd suggest a slightly different solution:

Counter = 0;
For select c1,c2 from TableA where c1=x and c2=y into :c1, :c2 do
begin
Counter = Counter+1;
suspend;
end;
If (Counter=0) then
For select c1,c2 from TableA where c1=x into :c1,:c2 do
suspend;

It is one select shorter and should work a bit faster.

SY, Dimitry Sibiryakov.