Function Returning SETOF Problem
| От | Ron St-Pierre |
|---|---|
| Тема | Function Returning SETOF Problem |
| Дата | |
| Msg-id | 3FE0F0B1.5080502@syscor.com обсуждение исходный текст |
| Ответы |
Re: Function Returning SETOF Problem
Re: Function Returning SETOF Problem |
| Список | pgsql-general |
On a daily basis I place a lot of data into the empty table dailyList,
and from that data update certain fields in currentList. I thought that
using a function would be a good way to do this(?). However I get the
following error when I run updateCurrentData():
ERROR: set-valued function called in context that cannot accept a set
CONTEXT: PL/pgSQL function "updatecurrentcata" line 6 at return next
I've googled and tried variations on the function, but without success.
Can anyone help?
Here's the function:
CREATE TYPE place_finish AS (first NUMERIC, second NUMERIC, third
NUMERIC, grandttl INTEGER, lname TEXT, fname TEXT);
CREATE OR REPLACE FUNCTION updateCurrentData() RETURNS SETOF
place_finish AS '
DECLARE
rec RECORD;
updstmt TEXT;
BEGIN
FOR rec IN SELECT first, second, third, grandttl, lname, fname
FROM dailyList LOOP
RETURN NEXT rec;
updstmt := ''UPDATE currentList SET first=rec.first,
second=rec.second, third=rec.third, grandttl=rec.grandttl,
lname=rec.lname, fname=rec.fname WHERE lname=rec.lname AND
fname=rec.fname;'';
EXECUTE updstmt;
END LOOP;
RETURN 1;
END;
' LANGUAGE 'plpgsql';
Thanks
Ron
ps postgres 7.4, debian stable
В списке pgsql-general по дате отправления: