SQL> create or replace function get_sal(name varchar2)
2 return number is
3 v_sal number(6,2);
4 begin
5 select sal into v_sal from emp where upper(ename)=upper(name);
6 return v_sal;
7 end;
8 /
Function created
SQL> var salary number
SQL> exec :salary:=get_sal('scott');
PL/SQL procedure successfully completed
调用该函数:
- SQL> var salary number
- SQL> exec :salary:=get_sal('scott');
- PL/SQL procedure successfully completed
- salary
- ---------
- 4000
阅读(2956) | 评论(0) | 转发(0) |