A positional parameter reference is typically used in a SQL function definition statement to indicate a parameter in a SQL function. The syntax to specify a parameter is:
Where ## acts as the index position of the parameter you are searching for. For example, the following function returns the title of a book when passed the isbn number.
Example 4-47. Creating a Function
booktown=# CREATE FUNCTION isbn_to_title(text) RETURNS text booktown-# AS 'SELECT title from books where isbn = $1' booktown-# LANGUAGE 'sql';
The $1 in the function definition is substituted with the first function argument when the function is called.
|Function List in psql|
Remember that to see a list of PostgreSQL's built-in functions, you may use the psql command \df .
If you want to delete your function after having created it, use the DELETE FUNCTION command. This command takes in the function name and type. Like this:
DELETE FUNCTION funcName(type);
If the inventory function was not needed anymore, then we can delete it using the command:
Example 4-48. Removing a Function
DELETE FUNCTION inventory(integer);