Re: help using count in function - Mailing list pgsql-novice

From Tom Lane
Subject Re: help using count in function
Date
Msg-id 25135.1099205514@sss.pgh.pa.us
Whole thread Raw
In response to help using count in function  ("Michaud, Everett" <EMichaud@sequoianet.com>)
List pgsql-novice
"Michaud, Everett" <EMichaud@sequoianet.com> writes:
> Perhaps this is simple, but it has me stumped.  What is the data type to
> use for returning a value from count?

int8, a/k/a bigint.  Or if you really want to return int4, you could
cast the count() result to int4.

> ERROR:  return type mismatch in function declared to return integer

I don't think any modern version of Postgres is that stingy with
information about this error.  I get either

ERROR:  return type mismatch in function: declared to return integer, returns bigint

or

ERROR:  return type mismatch in function declared to return integer
DETAIL:  Actual return type is bigint.

depending on which version I try.

            regards, tom lane

pgsql-novice by date:

Previous
From: "Sample, Matt (GE Healthcare)"
Date:
Subject: Bulk Loading into posgres 8.0.0
Next
From: Michael Fuhr
Date:
Subject: Re: help using count in function