declare

 v_ename emp.ename%type := 'A';

begin

 select ename into v_ename

 from emp

 where empno = &sv_empno;


 p(v_ename);

end;

/


Enter value for sv_empno: 7499


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


create or replace procedure p1 (a emp.empno%type)

is

 v_ename emp.ename%type default 'A';

begin

 select ename into v_ename

 from emp

 where empno = a;


 p(v_ename);

end;

/


show errors


exec p1(7499)

exec p1(7900)


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

  

create or replace procedure p2 (a emp.empno%type)

is

 emp_rec emp%rowtype;

begin

 select * into emp_rec

 from emp

 where empno = a;

 -- p(emp_rec.ename||' '||to_char(emp_rec.sal));


 p('Ename : '||emp_rec.ename);

 p('Sal   : '||to_char(emp_rec.sal));


end;

/


show errors


exec p2(7499)

exec p2(7900)


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

  

declare

 v_sal emp.sal%type;

 v_ret v_sal%type; --> 변수뒤에 %type 사용

begin

 select sal into v_sal

 from emp

 where empno = 7788;


 v_ret = v_sal + 10;


 p(v_sal);

 p(v_ret);

end;

/

+ Recent posts