DROP FUNCTION

DROP FUNCTION — remove a user defined function

Syntax

DROP FUNCTION [schema.]func_name [IF EXISTS] [/num_arg]
DROP FUNCTION [IF EXISTS] [schema.]func_name [/num_arg]

Description

DROP FUNCTION removes the definition of an existing function. If schema_name is not specified, an attempt will be made to drop a function with the specified func_name from the current schema. To execute this command the user must be the owner of the function. See CREATE FUNCTION to create a function.

Parameters

IF EXISTS

If the function does not exist and you specify IF EXISTS, NuoDB does not generate an error. Otherwise, if the function does not exist, an error is generated.

schema

Optional. The name of the schema that owns the function to be dropped. If schema is not provided, the function must be owned by the current schema.

func_name

Name of the function to remove.

num_arg

The number of input arguments defined. This is required if this function is defined as an overloaded function, meaning more than one function with the same name exists in the current schema, but each has a different number of input arguments.

Examples

Example 1: Creating and dropping a function.
CREATE FUNCTION function1 returns string as return 'test'; end_function;
DROP FUNCTION function1;
Example 2: Creating and dropping a function using argument count.
SET DELIMITER @
CREATE FUNCTION function2(arg BOOLEAN) RETURNS STRING
AS
    IF (arg = TRUE)
    RETURN 'True';
    END_IF;

    IF (arg = FALSE)
    RETURN 'False';
    END_IF;
END_FUNCTION@

SET DELIMITER;

SELECT function2(true) FROM dual;
 [TEST.FUNCTION2]
 ----------------
       True

DROP FUNCTION function2/1;