Pass constant to function : Function Parameter « Store Procedure Function « PostgreSQL






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=#

           
       








Related examples in the same category

1.Here the $1 references the value of the first function argument whenever the function is invoked
2.OUT parameter
3.Output parameters are most useful when returning multiple values
4.Real number parameter
5.Two out parameters
6.'Anyelement' parameter
7.Pass in a whole row
8.Use defined data type as the function parameter