Search Postgresql Archives

returning a resultset from a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

How do I return a result set? Is there a better way in 'plpgsql' than the one described below?
I do not want to make a select from a function(which pretty useful in many cases):
SELECT * FROM getfoo();
, but I want to just call the function with SELECT getfoo();


--DROP FUNCTION getfoo();
--DROP type compfoo;

CREATE TYPE compfoo AS (f1 integer,f2 integer);

CREATE OR REPLACE FUNCTION getfoo() RETURNS SETOF compfoo
AS
$BODY$
declare
    ret_row record;
BEGIN

     FOR ret_row IN SELECT id,mun_id FROM mytable LOOP

          RETURN next ret_row;

     END LOOP;
     
RETURN;
END;
$BODY$
  LANGUAGE 'plpgsql';



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux