Created
January 13, 2013 17:19
-
-
Save jatorre/4525165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create a function withn the security set to Definer so that it can insert | |
CREATE OR REPLACE FUNCTION cdb_insert_point(float, float) RETURNS integer | |
AS 'INSERT INTO example_table(the_geom) VALUES(ST_SetSRID(ST_MakePoint($1,$2),4326)) RETURNING cartodb_id;' | |
LANGUAGE SQL | |
SECURITY DEFINER | |
RETURNS NULL ON NULL INPUT; | |
--Grant access to the public user | |
GRANT EXECUTE ON FUNCTION cdb_insert_point(float,float) TO publicuser; | |
-- Call the new function like: | |
-- http://jatorre.cartodb.com/api/v1/sql?q=SELECT%20cdb_insert_point(8,8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment