[v1 V4WS] Does SUM work on ULong fields?

Steven Ronald stevenrt39 at yahoo.com.au
Wed Nov 15 10:32:04 CST 2006


Ruslan,

>I not remember such problem in v1.
>Should work.

>May be you have NULLs ?

I opened the database up with VAPP and can see each
field is populated with data for the 62 records, so it
can't be because I am trying to SUM nulls. It seems to
work OK for Double, not for Ulong fields.

Anyway, I believe all the fields I need to SUM are
Double so it is not a problem for me.

However, assuming I am using SUM only on Double
fields, what happens if I use SUM when no records are
found? I tested a few times and it gives 0 which makes
sense, but I am nervous about relying on this default
behaviour.

To be safe I can do this:

cursorRef=valSQLSelect( dbRef_xdb, "SELECT SUM(roop),
COUNT(roop) FROM x WHERE foo<5")

If valgetfield(cursorRef,2)=0 then
   sum=0
else
   sum=valgetfield(cursorRef,1)
end if

Is this necessary? Or can I just use

cursorRef=valSQLSelect( dbRef_xdb, "SELECT SUM(roop)
FROM x WHERE foo<5")

sum=valgetfield(cursorRef,1)

and if no records are found assume I will always get
sum=0?

Which is better?

Best Regards,
Steven




Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the Valentina mailing list