Basic Oracle Concepts and Programming Question:
What Is an Oracle Function?
Answer:
A function is a named program unit. It consists of three parts:
► Declaration Part - Defining the function name, calling parameters, return value type, local variables and local procedures. Declaration part is required.
► Execution Part - Defining execution logic with executable statements. Execution part is required.
► Exception Part - Defining error handling logic. Exception part is optional.
Here how a complete procedure should look like:
FUNCTION name (parameter_1, parameter_2) RETURN type AS
-- Declaration statements
BEGIN
-- Executable statements
RETURN value;
EXCEPTION
-- Error handling statements
END;
► Declaration Part - Defining the function name, calling parameters, return value type, local variables and local procedures. Declaration part is required.
► Execution Part - Defining execution logic with executable statements. Execution part is required.
► Exception Part - Defining error handling logic. Exception part is optional.
Here how a complete procedure should look like:
FUNCTION name (parameter_1, parameter_2) RETURN type AS
-- Declaration statements
BEGIN
-- Executable statements
RETURN value;
EXCEPTION
-- Error handling statements
END;
Previous Question | Next Question |
What Is a Procedure in Oracle? | How To Define an Anonymous Procedure without Variables? |