Lists: | pgsql-general |
---|
From: | "Szymic1" <dyrex(at)poczta(dot)onet(dot)pl> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | FOR from query - is it a bug ? |
Date: | 2006-07-06 14:37:17 |
Message-ID: | 1152196635.799197.188260@75g2000cwc.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
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
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Szymic1 <dyrex(at)poczta(dot)onet(dot)pl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: FOR from query - is it a bug ? |
Date: | 2006-07-06 18:50:53 |
Message-ID: | 20060706185053.GA48836@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Thu, Jul 06, 2006 at 07:37:17AM -0700, Szymic1 wrote:
> 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"
What log? What client are you using -- psql or something else?
Warnings like this can happen if a client application calls a libpq
function like PQgetvalue() without first checking whether the query
returned any tuples.
--
Michael Fuhr