Subject RE: [ib-support] SELECT in stored proc returns wrong value
Author Ann W. Harrison
At 11:43 PM 6/17/2001 +0200, Christian Gütter wrote:

>Interbase behaves differently in two situations which are almost the
>same.
>
>1) When doing a SELECT outside a stored proc, it returns NULLs.
>
>2) When doing the same SELECT inside a stored proc, it leaves the result
> variables untouched, they are not NULL.
>
>For me, this is not consistent behaviour.
>So one might call it a bug, not a serious one, but still a bug.

Sorry, no, it's not a bug. As Helen said, a select that returns
nothing doesn't change the variables used in the INTO clause. If
they were null to start, they'll still be null. If not, not.

Nor is the behavior of SUM a bug. The sum of zero rows is null.
Intuitive or not, that's the behavior required by the SQL standard.

As for doing a "select count (*) ... " before doing a select or
update, that's generally a terrible idea because it doubles the
amount of work done. If you expect the count to be in the range
0-10, not so bad, but still, it's much better to count the results
in the stored procedure.


Regards,

Ann
www.ibphoenix.com
We have answers.