PLSQL存储函数
封装的sql代码块
输出7788号员工年薪
代码如下(示例):
CREATE OR REPLACE FUNCTION FUNC_GETSAL(VEMPNO NUMBER) RETURN NUMBER; IS
VTOTALSAL NUMBER;
BEGIN
SELECT SAL * 12 + NVL(COMM, 0) INTO VTOTALSAL FROM EMP WHERE EMPNO = VEMPNO; RETURN VTOTALSAL
END;
调用过程
调用函数:
DECLARE
VSAL NUMBER;
BEGIN
VSAL:=FUNC_GETSAL(7788);
DBMS_OUTPUT.PUT_LINE(VSAL);
END