Subject Re: [ib-support] Using LIKE with a subquery
Author Woody
From: "Stevio" <redeagle@...>

> Thanks Woody. However, I'm not familiar with SUSPEND. How does it work?
>

SUSPEND is the keyword used in procedures to tell the server to return the
current record and wait for the next fetch instruction and signifies that
the procedure is a "selectable" procedure. Once all the return variables
(fields) are filled with the needed information, SUSPEND will return the
current information to the calling procedure or program. Each time the next
record is needed, the procedure loops to get the next record (or set of
information). See the language guide for a more complete explanation.

Here is a quick example. It is untested and typed in
off-the-top-of-my-head....

create procedure TestProc(MatchKey VarChar(15))
Returns(
Field1 Int,
Field2 VarChar(5)
);
As
Declare Variable TmpField VarChar(5);
Begin
For select SomeField from MyTable
Where SomeField = :MatchKey
Into :TmpField do
begin
for select Field1, Field2 from MyTable2
Where Field1 Like "%" || :TmpField || "%"
Into :Field1, :Field2 do
begin
SUSPEND;
end
end
end;


HTH
Woody (TMW)