Re: Using aggregate functions with SELECT INTO or FOR ..
От | Darren Ferguson |
---|---|
Тема | Re: Using aggregate functions with SELECT INTO or FOR .. |
Дата | |
Msg-id | Pine.LNX.4.44.0210241904190.31810-100000@thread.crystalballinc.com обсуждение исходный текст |
Ответ на | Using aggregate functions with SELECT INTO or FOR .. LOOP? (Frank Miles <fpm@u.washington.edu>) |
Ответы |
Re: Using aggregate functions .. (a BUG?)
|
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: