Created
August 3, 2011 19:09
-
-
Save booo/1123510 to your computer and use it in GitHub Desktop.
special insert for postgres
This file contains 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
--does not work... | |
CREATE OR REPLACE FUNCTION myinsert(tablename text, g geometry, s hstore) RETURNS integer AS $$ | |
DECLARE i integer; | |
DECLARE sequencename text; | |
DECLARE sql text; | |
BEGIN | |
sequencename = tablename || '_sequence_id'; | |
i = nextval(sequencename); | |
sql = 'INSERT INTO ' || tablename || '(id, geom, store) VALUES ('|| i ||', '|| g ||','|| s ||');'; | |
EXECUTE sql; | |
RETURN i; | |
END; | |
$$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment