Search code examples
oraclefunctionplsqloracle11greturn

How To Print Returned Value from PL/SQL Function


I have Problem with my code in PL/SQL

I need to return Max(Salary)

Myfunction is:

create or replace
FUNCTION largest_salary
(j_id EMPLOYEES.JOB_ID%TYPE)
return EMPLOYEES.SALARY%TYPE
IS
sal EMPLOYEES.SALARY%TYPE;

begin
select max(salary)
into sal
from employees
where job_id = j_id;
return sal;
end largest_salary;

and when i run this query :

set serveroutput out

Begin
dbms_output.put_line(largest_salary('SA_REP'));
End;

it doesn't show any thing , anyone can Help me get max(salary)?

Note :I Think it returns multiple values but i don't know how to solve it


Solution

  • You should use set serveroutput on instead of

    set serveroutput out