ALTER FUNCTION statement

Use this statement to modify a function. You must include the entire new function in the ALTER FUNCTION statement.

Syntax 1
ALTER FUNCTION [ owner.]function-name function-definition
function-definition : CREATE FUNCTION syntax
Syntax 2
ALTER FUNCTION [ owner.]function-name 
SET HIDDEN
Syntax 3
ALTER FUNCTION [ owner.]function-name
RECOMPILE
Remarks

Syntax 1   The ALTER FUNCTION statement is identical in syntax to the CREATE FUNCTION statement except for the first word. Either version of the CREATE FUNCTION statement can be altered.

Existing permissions on the function are maintained, and do not have to be reassigned. If a DROP FUNCTION and CREATE FUNCTION were carried out, execute permissions would have to be reassigned.

Syntax 2   Use SET HIDDEN to scramble the definition of the associated function and cause it to become unreadable. The function can be unloaded and reloaded into other databases.

Note

This setting is irreversible. If you will need the original source again, you must maintain it outside the database.

If SET HIDDEN is used, debugging using the debugger will not show the function definition, nor will it be available through procedure profiling.

Syntax 3   Use the RECOMPILE syntax to recompile a user-defined function. When you recompile a function, the definition stored in the catalog is re-parsed and the syntax is verified. The preserved source for a function is not changed by recompiling. When you recompile a function, the definitions scrambled by the SET HIDDEN clause remain scrambled and unreadable.

Permissions

Must be the owner of the function or have DBA authority.

Side effects

Automatic commit.

See also
Standards and compatibility
  • SQL/2003   Vendor extension.

Example

In this example, you create an event that instructs the database server to carry out an automatic backup of the transaction log only, every hour, Monday to Friday between 8 A.M. and 6 P.M.. Then, you issue an ALTER EVENT statement to change the event to be every two hours, between 9 A.M. and 5 P.M., on Mondays, Wednesdays, and Fridays.

CREATE EVENT HourlyLogBackup
SCHEDULE hourly_log_backup
BETWEEN '8:00AM' AND '6:00PM'
EVERY 1 HOURS ON
   ( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday')
HANDLER
   BEGIN
      BACKUP DATABASE DIRECTORY 'c:\\database\\backup'
      TRANSACTION LOG ONLY
      TRANSACTION LOG RENAME
   END;

ALTER EVENT HourlyLogBackup
ALTER SCHEDULE hourly_log_backup
BETWEEN '9:00AM' AND '5:00PM'
EVERY 2 HOURS ON
   ( 'Monday', 'Wednesday', 'Friday' );