ERROR: control reached end of function without RETURN

From: "Ignacio Colmenero" <ignacio(dot)colmenero(at)micotan(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: ERROR: control reached end of function without RETURN
Date: 2005-02-11 18:51:14
Message-ID: 20050211185117.RZHU6731.priv-edtnes57.telusplanet.net@ignacio
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all.

I created a function, using EMS:

CREATE OR REPLACE FUNCTION "geo_schema"."search_geo" () RETURNS SETOF
varchar AS

$body$

declare x_longlat cursor for select long_lat from h2s ;

declare var_longlat public.geometry ;

declare x_id varchar ;

begin

open x_longlat ;

<<loop1>>

loop

fetch x_longlat into var_longlat ;

if not found then

close x_longlat ;

exit ;

end if ;

select field_id from geo_table

where within(var_longlat, geo_polygon) limit 1 into x_id ;

if x_id <> '' then

return next x_id ;

end if ;

end loop ;

end ;

$body$

LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

When I debug it (using EMS tools), it works fine, and I get 73 rows, but
when I run it like:

select * from search_geo() ;

I get the error: ERROR: control reached end of function without RETURN

What can be wrong?

TIA

Ignacio.

-----------------------------------------------

Ignacio Colmenero

Software Development

Micotan Software Company Ltd.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-02-11 19:06:22 Re: test datatype for ANY
Previous Message Tom Lane 2005-02-11 18:48:35 Re: [GENERAL] WARNING: could not remove database directory