Search Postgresql Archives

FOR from query - is it a bug ?

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

 



I have function (below) that returns values in table format. But when
source table ( xxx.logic_list_item ) is empty I've got following
message in log:
"row number -1 is out of range 0..-1"

Is it a error message ? To be honest I do not know how to handle
situation when source table is empty, what should I return? In reposnse
I would like to see '0 rows found'

I'm using Postgress 8.1.

CREATE OR REPLACE FUNCTION freeconet.find_logic_items () RETURNS SETOF
xxx.logic_list_item  AS $$
DECLARE
v_logic_item xxx.logic_list_item;
BEGIN


       /* WYSZUKUJE logic_list_item w bazie */
       FOR v_logic_item IN select *  from xxx.logic_list_item LOOP
	return next v_logic_item;
       END LOOP;

       return;

END;
$$ LANGUAGE 'plpgsql' VOLATILE;

select * from xxx.find_logic_items()


Michal Szymanski



[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