You should alias the Aggregate function such as
CREATE OR REPLACE FUNCTION sp_test() RETURNS BOOLEAN AS '
DECLARE
rec RECORD;
BEGIN
SELECT SUM(a) AS asum,foo,bar INTO rec FROM test WHERE id = 1;
IF NOT FOUND THEN
RETURN FALSE;
END IF;
RAISE NOTICE ''%'',rec.asum;
RETURN TRUE;
END;' LANGUAGE 'plpgsql';
This should do what you wanted
HTH
On Thu, 24 Oct 2002, Frank Miles wrote:
> I would like to be able to use aggregate functions (e.g. sum(..))
> in a pl/pgsql functions through SELECT INTO and FOR record IN SELECT ...
> lines. The obvious (record.sum(..)) doesn't work when attempting to
> recover the values. Is there a simple way of getting this information?
>
> TIA!
>
> -frank
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
--
Darren Ferguson