Skip to content

Instantly share code, notes, and snippets.

@mexitek
Created August 26, 2011 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mexitek/1172401 to your computer and use it in GitHub Desktop.
Save mexitek/1172401 to your computer and use it in GitHub Desktop.
Postgre Function that fills in a table calls points with random Lat/Long for location field and a unique name
DECLARE
amount ALIAS FOR $1;
r_lat FLOAT;
r_lon FLOAT;
BEGIN
FOR v_Count IN 1..amount LOOP
r_lat := random()*360;
r_lon := random()*360;
INSERT INTO points (name_of_place,location) VALUES ( 'place_'||v_Count, makepoint( r_lat, r_lon) );
END LOOP;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment