Skip to content

Instantly share code, notes, and snippets.

@jatorre
Created Jan 13, 2013
Embed
What would you like to do?
-- 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