首页 > 代码库 > Oracle——函数

Oracle——函数

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;