What is a function?
What is a function?
Rating:
A function is a named PL/SQL block that can accept parameters and be invoked. Generally, a function is used to compute a value. A function is similar to a procedure except that a function must return a value to the calling environment, whereas a procedure may or may not return values to its calling environment. Like a procedure, a function has a header, a declarative part, an executable part, and an optional exception-handling part. A function must have a RETURN clause in the header and at least one RETURN statement in the executable section.
Functions can be stored in the database as a schema object for repeated execution. A function stored in the database is referred to as a stored function. Functions can also be created at client-side applications. Functions promote reusability and maintainability. They can be used in any number of applications. If the processing requirements of an application change, only the function needs to be updated.
Unlike a procedure, a function cannot be called as a stand-alone statement. It must be called as part of a SQL or PL/SQL expression.
Rating:
Other articles
- What is GRANT?
- What is sqlnet.ora?
- What is the Segment Advisor?
- What is a statement failure?
- What is the importance of ARCHIVELOG mode for various databases?