V4RB: Question to SUM

Ruslan Zasukhin sunshine at public.kherson.ua
Sat Jun 7 01:18:13 CDT 2003


on 6/6/03 23:46, Claudius Sailer at Claudius at sailer-online.de wrote:

Hi Claudius, 

> I am testing the following Code. A long Time ago, when SUM was first
> installed I got the information that SUM is much slower for few records
> than doing the same with a Routine in RB. Now I compared both and I
> think this not longer true. Could someone confirm that?

Hard to say. It crate tmp table on disk...
If you say that this is faster for you, then GOOD.

> An other question is. Is it possible to make the last row more
> effectiv? What is the result of SUM? a floatField?

Result of SUM() depend on its argument field.

If this is SIGNED INTEGEER, i.e.
    short, long, llong then result is LLONG

If this is UNSIGNED Integer, then result is ULLONG.

If this is float or double then result is double.


>  SQLString="SELECT SUM(Betrag)"
>  SQLString=SQLString+" FROM Buchungen"
>  SQLString=SQLString+ " WHERE Herk_Konto= "+KontoRecID
>  if NOT CheckLeer(Startdatum) then
>    SQLString=SQLString+ " AND BDatum>'"+StartDatum+"'"
>  end if
>  if NOT checkLeer(Enddatum) then
>    SQLString=SQLString+ " AND BDatum<='"+Enddatum+"'"
>  end if
> 
>  CurBuchungen=meineDatenbank.SQLselect(SQLString)
>  Ende=CurBuchungen.RecordCount
>  'field1=CurBuchungen.longfield(2) //Betrag
>  'for ii=1 to Ende
>  CurBuchungen.CurrentPosition=1
>  KontoStand=val(CurBuchungen.StringField(1).getString)
> 
> This row crashed RB ;-)) How does it have to look right? KontoStand is
> integer and the result is also an integer.
> 
>  KontoStand=CurBuchungen.FloatField(1).value
            
But what type have Betrag?

If it is float, then SUM() is double.

And you can resolve this problem self, if make next code:

    dim fld as Vfield

    fld = CurBuchungen.Field(1)
    
    Type = fld.Type



-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list