sqldatabasepostgresqlplpgsqldrop

PostgreSQL: Drop a function without parameters


I created a function as shown below:

CREATE FUNCTION my_func(value INTEGER) RETURNS VOID AS $$
BEGIN
END;
$$ LANGUAGE plpgsql;

But I need to specify the parameter to drop the function as shown below:

DROP FUNCTION my_func(value INTEGER);

Because if not specifying the parameter as shown below:

DROP FUNCTION my_func;

Then, I got the error below:

ERROR: function name "my_func" is not unique
HINT: Specify the argument list to select the function unambiguously.

So, can I drop a function without parameters?


Solution

  • In Postgres functions can be overloaded, so parameters are necessary to distinguish overloaded functions. To unambiguously identify a function you can put only types of its parameters.

    DROP FUNCTION my_func(INT);