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
---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings