Subject RE: [firebird-support] NULL confusion, again
Author Graeme Edwards
>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,

I find this one an interesting issue also and I am wondering if there is
some

subtle difference between a query that includes an aggregate like sum and

a query that simply returns a field.

It seems like an aggregate might return a recordset containing one row of

data where the field may have a null value as in this example while a query
that

returns a field returns a null recordset with no records where there is no

matching data. Maybe the value of total is set to null because there is a

recordset returned by the query with a field containing null.

I might have this totally wrong, so hopefully an expert will be able to

clarify this.

Graeme Edwards









++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





SPONSORED LINKS


Technical
<http://groups.yahoo.com/gads?t=ms&k=Technical+support&w1=Technical+support&
w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq
+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technic
al+support&c=6&s=196&.sig=-XIO8GxY6hqd3NaD5WSEyw> support

Computer
<http://groups.yahoo.com/gads?t=ms&k=Computer+technical+support&w1=Technical
+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&
w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsof
t+technical+support&c=6&s=196&.sig=B29J78SYXnNTjjMFBMznqA> technical
support

Compaq
<http://groups.yahoo.com/gads?t=ms&k=Compaq+computer+technical+support&w1=Te
chnical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+s
upport&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=M
icrosoft+technical+support&c=6&s=196&.sig=7_je1A94xs82CFXUjEqA6g> computer
technical support


Compaq
<http://groups.yahoo.com/gads?t=ms&k=Compaq+technical+support&w1=Technical+s
upport&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4
=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+
technical+support&c=6&s=196&.sig=2zMAuRCo5cJrVBr1Bxa3_w> technical support

Hewlett
<http://groups.yahoo.com/gads?t=ms&k=Hewlett+packard+technical+support&w1=Te
chnical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+s
upport&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=M
icrosoft+technical+support&c=6&s=196&.sig=_ytYU7aXb57AVaeUfmvLcA> packard
technical support

Microsoft
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+technical+support&w1=Technica
l+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support
&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microso
ft+technical+support&c=6&s=196&.sig=4hRo6NXYavRAbTkaYec5Lw> technical
support



_____

YAHOO! GROUPS LINKS



* Visit your group "firebird-support
<http://groups.yahoo.com/group/firebird-support> " on the web.

* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>

* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.



_____



[Non-text portions of this message have been removed]