postgres=# -- Using variable declaration options
postgres=#
postgres=# CREATE FUNCTION example_function () RETURNS text AS '
postgres'# DECLARE
postgres'#
postgres'# -- Declare a constant integer with a default value of 5.
postgres'# five CONSTANT INTEGER := 5;
postgres'#
postgres'# -- Declare an integer with a default value of 100 that cannot be NULL.
postgres'# ten INTEGER NOT NULL := 10;
postgres'#
postgres'# -- Declare a character with a default value of "a".
postgres'# letter CHAR DEFAULT ''a'';
postgres'#
postgres'# BEGIN
postgres'# return letter;
postgres'# END;
postgres'# ' LANGUAGE 'plpgsql';
CREATE FUNCTION
postgres=#
postgres=# select example_function ();
example_function
------------------
a
(1 row)
postgres=#
postgres=# drop function example_function ();
DROP FUNCTION
postgres=#
postgres=#
|