Subject | NULL confusion, again |
---|---|
Author | t.s. |
Post date | 2006-04-21T01:08:26Z |
Hello,
The other day i posted a rather lengthy message about a (self-induced)
bug because i did not initialize a variable properly. The conclusion i
get from the response to that post is that these are 'normal' constructs
in firebird's stored procedure language :
...
total = 0;
select sum(...) form other_table into :total;
...
Again, if i understood Ms Helen Borrie's message correctly, if the
select returns NULL, the variable total will not be affected, so it will
be still be zero.
Today (at 5 AM, duh), i encountered another case with these lines :
...
total = 0;
select sum(detail.amount)
from master
join detail on (master_id = detail_id
where (master.trans_date < :end_date) and
(detail.item_id = :item_id)
into :total;
...
Since the tables are empty, the result of the variable TOTAL is always
NULL inside this stored procedure (Firebird 1.5.3, Win32). This kinda
contradicts my conclusion above (about how a SELECT INTO that returns a
NULL will not affect the variable value).
Just thought i'm gonna post this here before i went to bed :)
Thank you all in advance,
t.s.
The other day i posted a rather lengthy message about a (self-induced)
bug because i did not initialize a variable properly. The conclusion i
get from the response to that post is that these are 'normal' constructs
in firebird's stored procedure language :
...
total = 0;
select sum(...) form other_table into :total;
...
Again, if i understood Ms Helen Borrie's message correctly, if the
select returns NULL, the variable total will not be affected, so it will
be still be zero.
Today (at 5 AM, duh), i encountered another case with these lines :
...
total = 0;
select sum(detail.amount)
from master
join detail on (master_id = detail_id
where (master.trans_date < :end_date) and
(detail.item_id = :item_id)
into :total;
...
Since the tables are empty, the result of the variable TOTAL is always
NULL inside this stored procedure (Firebird 1.5.3, Win32). This kinda
contradicts my conclusion above (about how a SELECT INTO that returns a
NULL will not affect the variable value).
Just thought i'm gonna post this here before i went to bed :)
Thank you all in advance,
t.s.