본문 바로가기
개발/sql

oracle 중간점검

by 카앙구운 2015. 10. 7.
728x90
반응형

ed empCnt


create or replace function empCnt

(v_number in number)

return varchar2

is

v_cnt number;

v_empcnt varchar2(100);

v_page number;

begin

select count(*) into v_cnt from emp;

v_page :=ceil(v_cnt/v_number);

v_empcnt := v_cnt || '/'|| v_page;

return v_empcnt;

end;

/


-------------------------------------------


create or replace function empno_mgr

(v_empno emp.empno%type)

return varchar2

is

v_mgr varchar2(100);

v_deptno number;

v_ename varchar2(100);

v_dname varchar2(100);

begin

select mgr,deptno into v_mgr,v_deptno from emp where empno=v_empno;

select ename into v_ename from emp where empno=v_mgr;

select dname into v_dname from dept where deptno=v_deptno;

dbms_output.put_line('사원번호:'||v_mgr);

dbms_output.put_line('성    명:'||v_ename);

dbms_output.put_line('부 서 명:'||v_dname);

return v_mgr;

end;

/

728x90
반응형

댓글