Subject | Re: SELECT in stored proc returns wrong value |
---|---|
Author | dianeb77@hotmail.com |
Post date | 2001-06-19T14:41:46Z |
--- In ib-support@y..., "Ann W. Harrison" <aharrison@i...> wrote:
less.
(If the select returns nothing then the values of variables are not
changed, as per SQL92 rules; however, there should be a completion
condition to let you know that there was no data returned. I don't
know if that part's being done, or not.)
From SQL92, various places:
"1) Let Q be the result of <query specification> S.
2) Case:
<...>
b) If Q is empty, then no SQL-data values are assigned to any targets
identified by the <select
target list>, and a completion condition is raised: no data.
c) Otherwise, values in the row of Q are assigned to their
corresponding targets."
From SQL92, subclause 6.5 <set function specification>:
"<...>
b) If AVG, MAX, MIN, or SUM is specified, then
Case:
i) If TXA [that's the result set of the query] is empty, then the
result is the null value."
Cheers,
db
> At 11:43 PM 6/17/2001 +0200, Christian Gütter wrote:the
>
> >Interbase behaves differently in two situations which are almost
> >same.result
> >
> >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
> > variables untouched, they are not NULL.For what it's worth, this behaviour conforms to SQL standard, more or
> >
> >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.
less.
(If the select returns nothing then the values of variables are not
changed, as per SQL92 rules; however, there should be a completion
condition to let you know that there was no data returned. I don't
know if that part's being done, or not.)
From SQL92, various places:
"1) Let Q be the result of <query specification> S.
2) Case:
<...>
b) If Q is empty, then no SQL-data values are assigned to any targets
identified by the <select
target list>, and a completion condition is raised: no data.
c) Otherwise, values in the row of Q are assigned to their
corresponding targets."
> Nor is the behavior of SUM a bug. The sum of zero rows is null.Yup.
> Intuitive or not, that's the behavior required by the SQL standard.
From SQL92, subclause 6.5 <set function specification>:
"<...>
b) If AVG, MAX, MIN, or SUM is specified, then
Case:
i) If TXA [that's the result set of the query] is empty, then the
result is the null value."
Cheers,
db