Skip site navigation (1) Skip section navigation (2)

return setof record - strange behavior

From: "Marcin Krawczyk" <jankes(dot)mk(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: return setof record - strange behavior
Date: 2008-08-04 09:53:21
Message-ID: 95f6bf9b0808040253o371f7929l7845e7f7826cacdf@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hi everybody. Can anyone enlighten me what's wrong with this function :

CREATE OR REPLACE FUNCTION month_year(mon integer, intv integer, OUT
ro integer, OUT mi integer)
  RETURNS SETOF record AS
$BODY$
DECLARE
w	record;
cy	integer := EXTRACT (YEAR FROM current_date);

BEGIN

FOR w IN
	SELECT (CASE WHEN  m > 12 THEN cy + 1 ELSE cy END)::integer, (CASE
WHEN  m > 12 THEN m - 12 ELSE m END)::integer
	FROM generate_series(mon + 1, mon + intv) AS m
LOOP
	RETURN next;
END LOOP;

END;

$BODY$
  LANGUAGE 'plpgsql' VOLATILE;


SELECT * FROM month_year(10, 5);

Why does it return empty SET ? The amount of rows is correct though ....
I'm running 8.1.4

regards
mk

Responses

pgsql-sql by date

Next:From: Marcin KrawczykDate: 2008-08-04 10:08:26
Subject: return setof record - strange behavior
Previous:From: Scott MarloweDate: 2008-08-02 01:07:08
Subject: Re: [SQL] Savepoints and SELECT FOR UPDATE in 8.2

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group