개발/sql

oracle sql

카앙구운 2015. 10. 5. 00:00
728x90
반응형

declare

v_no  emp.empno%type :=&res_no;

v_cnt number;

v_sal emp.sal%type;

v_sal2 emp.sal%type :=0;

begin

select count(*) into v_cnt from emp

where empno = v_no;

if v_cnt =0 then

dbms_output.put_line(v_no ||'는 없는 번호 입니다.');

else

select sal into v_sal from emp where empno=v_no;

if v_sal >=4000 then

v_sal2 :=v_sal +400;

elsif v_sal >=3000 then

v_sal2 :=v_sal +300;

elsif v_sal >=2000 then

v_sal2 :=v_sal +200;

else

v_sal2 :=v_sal +100;

end if;

update emp set sal=v_sal2 where empno =v_no;

end if;

end;

/

728x90
반응형