Re: Weird problem with aggregate functions

Поиск
Список
Период
Сортировка
От Andrea Aime
Тема Re: Weird problem with aggregate functions
Дата
Msg-id 3BE7C008.CAB90063@comune.modena.it
обсуждение исходный текст
Ответ на Weird problem with aggregate functions  ("Andrea Aime" <aaime@comune.modena.it>)
Ответы Re: Weird problem with aggregate functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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@postgresql.org)
> >
> >
> >
> >
> >
> >------=_ieG_NextPart_40087518038424658754559999576835.1
> --
>  Gustavo Pichorim Boiko
>  ----------------------------------------
>  Slackware 8.0 - Kernel 2.4.9-ac9
>  Linux User: 231003
>  ICQ (Licq): 86128708
>  ----------------------------------------
>  gustavoboiko@ieg.com.br
>
> http://www.ieg.com.br

В списке pgsql-odbc по дате отправления:

Предыдущее
От: Hiroshi Inoue
Дата:
Сообщение: Re: Weird problem with aggregate functions
Следующее
От: "Alan R. Johns"
Дата:
Сообщение: Access 2000 & Views