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