[postgis-users] writing loop and conditionals in pl/pgsql
Hi all, I am quite new to pl/pgsql and completely confused. I have two tables. One storing height category including hk_id(height category id), h_min and h_max. and a table including several plygons having y_max and height. My aim is to know on which height category the plygon locates based on its y_max. My piece of code is like: i=1; a=0; while (i=4 , a=0){ if h(i)_min y_max h(i)_max {height = i a = 1;} i = i + 1 } Is there any body who can help me to convert this piece of code to excutable format in pl/pgsql? Thank you in advance Many___ postgis-users mailing list postgis-users@lists.osgeo.org http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Re: [postgis-users] writing loop and conditionals in pl/pgsql
http://www.postgresql.org/docs/9.3/static/plpgsql.html I'm not sure you need plpgsql for this, looks like you could do in sql only (maybe even no need of CASE WHEN) Cheers, Rémi-C 2014-03-05 17:38 GMT+01:00 mane moshref many_ya...@yahoo.com: Hi all, I am quite new to pl/pgsql and completely confused. I have two tables. One storing height category including hk_id(height category id), h_min and h_max. and a table including several plygons having y_max and height. My aim is to know on which height category the plygon locates based on its y_max. My piece of code is like: i=1; a=0; while (i=4 , a=0){ if h(i)_min y_max h(i)_max {height = i a = 1;} i = i + 1 } Is there any body who can help me to convert this piece of code to excutable format in pl/pgsql? Thank you in advance Many ___ postgis-users mailing list postgis-users@lists.osgeo.org http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@lists.osgeo.org http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Re: [postgis-users] writing loop and conditionals in pl/pgsql
select * from tab1, tab2 Where tab1.hk_id = tab2.hk_id -- Assuming you have a ID column in both tables . . . AND tab2.y_max tab1.h_max AND tab2.y_max tab1.h_min order by tab2.height Bobb From: postgis-users-boun...@lists.osgeo.org [mailto:postgis-users-boun...@lists.osgeo.org] On Behalf Of mane moshref Sent: Wednesday, March 05, 2014 10:38 AM To: postgis-users@lists.osgeo.org Subject: [postgis-users] writing loop and conditionals in pl/pgsql Hi all, I am quite new to pl/pgsql and completely confused. I have two tables. One storing height category including hk_id(height category id), h_min and h_max. and a table including several plygons having y_max and height. My aim is to know on which height category the plygon locates based on its y_max. My piece of code is like: i=1; a=0; while (i=4 , a=0){ if h(i)_min y_max h(i)_max {height = i a = 1;} i = i + 1 } Is there any body who can help me to convert this piece of code to excutable format in pl/pgsql? Thank you in advance Many ___ postgis-users mailing list postgis-users@lists.osgeo.org http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Re: [postgis-users] writing loop and conditionals in pl/pgsql
Thanks guys. But first of all I have to do this with pl/pgsql. This is not the matter of having answer in my db. It is the matter of solving problem with pl/pgsql. Rémi-C thank you for the link. I already went through it but it just explain very basic structure. I couldn't find my answers there. Bobb, I don't have any hk_id in my polygons table. I am going to find it and sign their h_id in the table. Do you know how to write this part in pl format? then I think I would understand how to go through the rest of my code. Cheers___ postgis-users mailing list postgis-users@lists.osgeo.org http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users