Differences Between CREATE FUNCTION and REPLACE FUNCTION
A function can be created or replaced using the same syntax except for the keywords CREATE and REPLACE.
If you specify CREATE, the function must not exist.
If you specify REPLACE, you can either create a new function or replace an existing function with the following restriction: if the function to be replaced was originally created with a specific function name, then that specific function name must be used for the REPLACE FUNCTION statement.
When you replace an existing function, the replaced function does not retain the EXECUTE NOT PROTECTED attribute if one had previously been set using the ALTER FUNCTION statement (see “ALTER FUNCTION (External Form)” on page 15).
The advantage to using REPLACE is that you can avoid having to grant the EXECUTE privilege again to all users who already had that privilege on the function.
There are two important restrictions on replacing UDFs that perform UDT‑related functionality:
This means that the function name, parameter list, method entry point name within the EXTERNAL clause, and so on must all match.
If the UDF is currently set to run in the EXECUTE NOT PROTECTED mode, then you must submit an ALTER FUNCTION statement (see “ALTER FUNCTION (External Form)” on page 15) to switch the mode to EXECUTE PROTECTED before you can submit the REPLACE FUNCTION statement.
a DROP CAST
b REPLACE FUNCTION
c CREATE CAST
An attempt to directly replace a casting function using REPLACE FUNCTION results in an aborted request and returns an error to the requestor.