Restrictions When Calling User Defined Functions From SQL Statements in Oracle PL/SQL
One of the powerful features of PL/SQL is Stored Function. A Function is a named PL/SQL block that can accept parameters and return a value. It is similar to Procedure which is also accept parameters and return one or more values through OUT parameters but one of the advantages of function over procedure is that we can call it as a part of expression from the SELECT statement. However, the following restrictions apply when calling functions from SQL statements. 1. Function called from a SELECT statement cannot contain DML statements. Let's see what happen when I call a function containing DML statements from a SELECT statement. I considered employees table of the HR schema and created the following function which contains an UPDATE statement that updates the salary of an employee and returns the updated salary. CREATE OR REPLACE FUNCTION update_sal(P_emp_id IN NUMBER, P_sal IN NUMBER) RETURN NUMBER IS L_new_sal NUMBER; BEGIN