Skip to content

Instantly share code, notes, and snippets.

@booo
Created August 3, 2011 19:09
Show Gist options
  • Save booo/1123510 to your computer and use it in GitHub Desktop.
Save booo/1123510 to your computer and use it in GitHub Desktop.
special insert for postgres
--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