Using a RETURN NEXT

From: Mr Weinbach, Larry <larryweinbach(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Using a RETURN NEXT
Date: 2003-06-06 22:14:35
Message-ID: 20030606221435.44876.qmail@web12906.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

I found this example from Postgres site

create or replace function GetRows(text) returns setof
record as
'
declare
r record;
begin
for r in EXECUTE ''select * from '' || $1 loop
return next r;
end loop;
return;
end
'
language 'plpgsql';

I am trying to use the same idea but in this way ..

CREATE OR REPLACE FUNCTION word_case() RETURNS setof
RECORD AS'
DECLARE
reg record;
BEGIN
FOR reg IN SELECT message FROM rtable LOOP
RETURN next reg;
END LOOP;
RETURN;
END;
' LANGUAGE 'plpgsql';

But at execution time I am getting thi error :

WARNING: Error occurred while executing PL/pgSQL
function word_case
WARNING: line 5 at return next
ERROR: Set-valued function called in context that
cannot accept a set

I also tried using my own type defined but I got the
same error.

Any hint or idea will be appreciated ...

Regards

Larry

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rod Taylor 2003-06-07 13:48:08 Re: Column limits in table/ views
Previous Message Stephan Szabo 2003-06-06 17:04:04 Re: simulating partial fkeys.. [ATTN Developers please]