Created
September 7, 2012 14:21
-
-
Save neilalbrock/3666613 to your computer and use it in GitHub Desktop.
PostgreSQL Dynamic SQL Function
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
CREATE OR REPLACE FUNCTION name(arg datatype) | |
RETURNS TABLE(column datatype) AS | |
$$ | |
BEGIN | |
RETURN QUERY EXECUTE 'SELECT * FROM table WHERE column = $1' USING arg; | |
END; | |
$$ | |
LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment