DROP PROCEDURE statement¶
The DROP PROCEDURE statement deletes a user-defined procedure (UDP) in the used schema.
Note
An operation involving a non-default schema or an object in it requires access to the schema, either implicitly or through an explicit USAGE grant, as well as the privilege required for the operation. The schema access check and the privilege check for the requested operation are independent; satisfying one does not satisfy the other. Schema access control does not apply to temporary graphs or built-in procedures and functions. For more information, see Schema access control.
Prerequisites¶
- The UDP is created. For more information, see CREATE PROCEDURE.
- To delete a UDP, you must either be the owner of the UDP, be granted to perform the action
DROPon the UDP, or be granted to perform the actionDROP ANY PROCEDUREon the used schema. For more information, see Roles and privileges.
Syntax¶
- drop_procedure_statement
- parameter_declaration
drop_procedure_statement ::=
'DROP' 'PROCEDURE' ('IF EXISTS')? procedure_name ( '(' ( parameter_declaration ( ',' parameter_declaration )* )? ')' )?
parameter_declaration ::=
parameter_name? parameter_type ('DEFAULT' default_value )?
Parameters¶
IF EXISTS¶
This clause checks if the UDP to be deleted exists. If it does not exist, the UDP is not deleted and no exception is thrown.
If you do not specify this clause, an exception is thrown if the UDP to be deleted does not exist.
procedure_name¶
The name of the UDP to be deleted.
To delete a UDP by name, ensure no other UDP with the same name exists in the used schema. Otherwise, you must specify both the name and parameter type to uniquely identify the UDP to be deleted.
parameter_name¶
The name of the input parameter accepted by the UDP.
parameter_type¶
The data type of the input parameter accepted by the UDP.
default_value¶
The default value of the input parameter.
Examples¶
Drop a UDP by name¶
'''
// Create UDP `test1`
CREATE OR REPLACE PROCEDURE test1() RETURNS ret INT AS { RETURN 1 }
'''
'''
DROP PROCEDURE test1
'''
Drop a UDP by name and parameter type¶
'''
// Create UDP `test2`
CREATE OR REPLACE PROCEDURE test2(a INT, b STRING) RETURNS ret INT AS { RETURN a }
'''
'''
DROP PROCEDURE test2(INT, STRING)
'''