Skip to content

Instantly share code, notes, and snippets.

@choplin
Created September 5, 2012 11:20
Show Gist options
  • Select an option

  • Save choplin/3635223 to your computer and use it in GitHub Desktop.

Select an option

Save choplin/3635223 to your computer and use it in GitHub Desktop.
DROP FUNCTION eval(text);
CREATE FUNCTION eval(sql Text) RETURNS SETOF Record AS $$
BEGIN
RETURN QUERY EXECUTE sql;
RETURN;
END;
$$ LANGUAGE plpgsql;
SELECT * FROM eval('SELECT * FROM( VALUES (1,''a''), (3,''b'') ) AS t') AS (i Int, c Text);
DROP FUNCTION
CREATE FUNCTION
i | c
---+---
1 | a
3 | b
(2 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment