'PL/SQL'에 해당되는 글 1건


About The Search in Posts

오라클 PL / SQL

프로시저

1.  사원의 이름을 입력하면 사원번호를 구해오는 Procedure 작성하기

SQL> create or replace procedure ex1
         (emp_name  in emp.ename%TYPE,
           emp_num  out emp.empno%TYPE)
          IS
          begin
          select empno into emp_num
          from emp 
          where ename=emp_name;
          end;
           /

실행 :
SQL> variable num number;
SQL> execute ex1('MARTIN', :num);
SQL> print  num;

2.  사원 번호를 입력받아 메니저의 이름을 구해오는 Function으로 작성하기

SQL> create  function  getMgr
        ( p_no    emp.empno%TYPE)
         return  varchar2
         IS
         v_name  varchar2(20);
         Begin
         select  ename INTO v_name from emp
         where empno=(Select mgr from emp
         where empno=p_no);
         return v_name;
         END;
          /

실행
SQL> select sal from emp 
         where ename=getMgr(7900);

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기
2008/06/18 20:30 2008/06/18 20:30

About this entry


Trackback Address : http://myjun.org/trackback/447

[로그인][오픈아이디란?]

Post a comment

       



Tag Cloud

Authors

  1. myjun

Categories

전체 (484)
Thinking (312)
Information (28)
Collection (15)
Travel (35)
English (13)
braces (31)
Book (4)
Hobby (38)
Programming (8)

Menu

Counts

  • Total : 278754
    Today : 42
    Yesterday : 218

Notice

Calendar

«   2009/07   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

History