Mega Code Archive

 
Categories / PostgreSQL / Store Procedure Function
 

Pass constant to function

postgres=# postgres=# CREATE FUNCTION "you_me" (integer) RETURNS integer AS ' postgres'#   DECLARE postgres'#    RENAME $1 TO user_no; postgres'#     --you INTEGER := 5; postgres'#   BEGIN postgres'#     return user_no; postgres'#   END;' LANGUAGE 'plpgsql'; CREATE FUNCTION postgres=# postgres=# select you_me(1);  you_me --------       1 (1 row) postgres=#