From: | "Andrea Aime" <aaime(at)comune(dot)modena(dot)it> |
---|---|
To: | gustavoboiko(at)ieg(dot)com(dot)br, Postgres ODBC <pgsql-odbc(at)postgresql(dot)org> |
Subject: | Re: Weird problem with aggregate functions |
Date: | 2001-11-06 10:48:40 |
Message-ID: | 3BE7C008.CAB90063@comune.modena.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-odbc |
Thanks, it works!!! But why doesn't it work without the
cast? This is a good workaround, but the standard behaviour
is a bug, isn't it?
Best regards
Andrea Aime
Gustavo Boiko wrote:
>
> if you are using ODBC driver, try to execute "SELECT SUM(field)::int4" or "SELECT
> CAST(SUM(field) as int4)"
>
> The results are OK when I tried this.
>
> >Hi everybody,
> >I got a problem with aggregate functions from VB 6. SUM, AVG, STDDEV,
> >and VARIANCE doesn't work on int4 types (but they're working on float8),
> >whereas MAX and MIN work also on int4... that's weird!
> >Even more strange, the above functions work both from psql and from
> >pgAdmin II... but not in the following code:
> >
> >Private Sub Form_Load()
> > Dim conn As ADODB.Connection
> > Dim rec As ADODB.Recordset
> > Dim cmd As Command
> >
> > Set conn = New Connection
> > conn.CursorLocation = adUseClient
> > conn.Open "DSN=DatabaseSIA"
> >
> > Set rec = New Recordset
> >
> > rec.Open "Select SUM(popolazione) from tab2531", conn, adOpenStatic,
> >adLockReadOnly
> > Me.Print rec.Fields(0).Name & ": " & rec.Fields(0).Value
> > rec.Close
> >End Sub
> >
> >where tab2531 is defined as follows:
> >
> >CREATE TABLE "tab2531" (
> > "abbreviazione" text,
> > "regione" int4,
> > "popolazione" int4,
> > "densita" int4,
> > "natalita" float8,
> > "mortalita" float8,
> > "mortalinfant" float8,
> > "nuzialita" float8
> >);
> >
> >The program halts with this error (translated from italian): "data
> >provider
> >or another service returned E_FAIL"
> >I tested this with 7.01.0008 and 7.01.0007 both on WinNT and Win2000...
> >same results. I also played with driver options. commlog doesn't report
> >any error. Ah, I use ADO 2.6 (tested also with 2.5, same results)
> >Any idea?
> >Best regards
> >Andrea Aime
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >
> >
> >
> >
> >
> >------=_ieG_NextPart_40087518038424658754559999576835.1
> --
> Gustavo Pichorim Boiko
> ----------------------------------------
> Slackware 8.0 - Kernel 2.4.9-ac9
> Linux User: 231003
> ICQ (Licq): 86128708
> ----------------------------------------
> gustavoboiko(at)ieg(dot)com(dot)br
>
> http://www.ieg.com.br
From | Date | Subject | |
---|---|---|---|
Next Message | Hiroshi Inoue | 2001-11-06 10:55:55 | Re: Weird problem with aggregate functions |
Previous Message | Andrea Aime | 2001-11-06 10:20:56 | Weird problem with aggregate functions |