0

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;

1 Answer 1

1
 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

should be

WHILE x > -36.4 LOOP
    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 LOOP ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.