Subject Re: [ib-support] SP and ODBC MFC
Author Frank Ingermann
Hello Zak,

zmahomedy wrote:
> Hi, I am using ODBC MFC API with firebird.
> I created a Store procedure thats selects a record, process it and
> returns the results. However if no results we found, MFC always gets
> a result of empty values. The recordset in MFC will always have 1
> row of data which will break my code as i cant check for BOF in the
> cursor position to determin if any records were found.
>
> Basic structor of my SP is as follows
>
> ...
> RETURNS(
> return1,
> return2,
> return3
> )
> ...
> BEGIN
> SELECT var1, var2, var3 FROM TABLE WHERE condition = condition1
> into : return1, :return2 , return3:
> SUSPEND;
> ...
>
> How would i adjust my SP so that if no records are found MFC will
> not get a recordset of garabe values.

what happens when you change the sp to:

BEGIN
FOR SELECT var1, var2, var3
FROM TABLE
WHERE condition = condition1
INTO :return1, :return2 , :return3
DO BEGIN
SUSPEND;
EXIT;
END
EXIT;
END

(untested, just "from the hip")

in your example you use a simple Select, and a Suspend afterwards. So afaikt the
sp *must* return at least one row. with the FOR Select loop, if no records are
found, nothing is returned, so you should get an eof directly - i hope ;-)

regards & hth,
fingerman

--
-------------------------------------------------------------------------
when parsers parse, and compilers compile, then why don't objects object?

fingerbirdy - fingerman's door to Firebird
http://www.fingerbird.de