From: | Christopher Murtagh <christopher(dot)murtagh(at)mcgill(dot)ca> |
---|---|
To: | postgres general <pgsql-general(at)postgresql(dot)org> |
Subject: | plpgsql return setof integer? |
Date: | 2003-11-12 22:35:40 |
Message-ID: | 1068676539.2824.10.camel@mafalda.murtagh.name |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Greetings,
I've got a fairly simple function that I'm trying to return a set, but
seem to have come across a stumbling block. When I execute the function
below (the input params are not used at the moment) I get this:
chris=# select htdig('foo', 'foo');
ERROR: set-valued function called in context that cannot accept a set
CONTEXT: PL/pgSQL function "htdig" line 14 at return next
CREATE OR REPLACE FUNCTION htdig(text, text) RETURNS SETOF integer AS '
DECLARE
result text[];
low integer;
high integer;
item integer;
BEGIN
result := htsearch(''sample_return.txt'',''dbname'');
low := 2;
high := array_upper(result, 1);
FOR i IN low..high LOOP
item := result[i];
RETURN NEXT item;
END LOOP;
RETURN;
END;
' LANGUAGE 'plpgsql' STABLE STRICT;
The function htsearch is working as expected (other than a strange HASH
as the first element, but I've compensated for that by starting at array
index 2). This is what it outputs:
chris=# select htsearch('sample_return2.txt','dbname');
htsearch
----------------------------------
{HASH(0x835c298),2100,2113,2114}
(1 row)
Any obvious thing that I'm doing wrong? I'm using 7.4RC2. As always, any
help or info would be much appreciated. Bonus points if someone knows
what the HASH is. :-)
Cheers,
Chris
--
Christopher Murtagh
Enterprise Systems Administrator
ISR / Web Communications Group
McGill University
Montreal, Quebec
Canada
Tel.: (514) 398-3122
Fax: (514) 398-2017
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2003-11-12 22:36:12 | Re: serial type vs. sequences |
Previous Message | Greg Stark | 2003-11-12 22:35:28 | Re: SQL-question: returning the id of an insert querry |