I'm getting the above error in my code, which indicates the 'while' line. I'm trying to find the number of intersection points to a line on some gis data. I've copied the code verbatim, the postgis code shouldn't affect the problem. (And if I'm trying to do this in a really stupid way, please say. I'm only a beginner)
create or replace function border() returns table(x real, sum bigint) as $$
declare x real;
begin
x := -35.5724;
while x > -36.4 do
return query select x,sum(st_npoints(st_intersection(the_geom,st_setsrid(st_makeline(st_point(173.3,x),st_point(175,x)),4167)))) from auckland_numberlines;
x := x - 0.1;
end while
end
$$ language plpgsql;