Explain the difference between a function and a procedure in Oracle PL/SQL.

1 Answers
Answered by suresh

Difference between Function and Procedure in Oracle PL/SQL

Oracle Developer Interview Question: Explain the difference between a function and a procedure in Oracle PL/SQL

In Oracle PL/SQL, functions and procedures are both subprograms that can be created to perform specific tasks. However, they have some key differences:

Function:

  • A function is a subprogram that returns a value.
  • It must return a single value using the RETURN statement.
  • Functions can be used in SQL queries or expressions.
  • Functions are called in SQL queries using SELECT statement.

Procedure:

  • A procedure is a subprogram that performs a specific task without returning a value.
  • It does not have a RETURN statement as it does not return any value.
  • Procedures cannot be used in SQL queries or expressions.
  • Procedures are called directly using CALL or EXECUTE statement.

Overall, functions are used to return a single value that can be used in SQL queries, while procedures are used to perform tasks without returning any value.

Answer for Question: Explain the difference between a function and a procedure in Oracle PL/SQL.