CREATE FUNCTION
annual_income(spNAme VARCHAR2) RETURN
NUMBER IS yearSal
number(7,2);
BEGIN
SELECT (sal+NVL(comm,0))*12 INTO yearSal FROM emp WHERE ename=spNAme;
RETURN yearSal;
END;
/
SQL> var income number;
SQL> call annual_income(‘SMITH‘)
into:income;
SELECT annual_income(ename) from emp;
Oracle——函数,码迷,mamicode.com
时间: 2024-10-13 21:40:26