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;
/
'Oracle > PL/SQL' 카테고리의 다른 글
15일차 # 3-3: Lexical Unit (어휘단위) (0) | 2012.04.24 |
---|---|
15일차 # 2-28: set autoprint on (set autop on) (0) | 2012.04.24 |
15일차 # 2-22: %TYPE attribute (0) | 2012.04.24 |
15일차 # 2-29: 치환 변수 + 바인드 변수 (0) | 2012.04.24 |
15일차 # 2-25: Bind variables (0) | 2012.04.24 |