티스토리 뷰
set serveroutput on
set autoprint on
old&new 없애려면 : set verify off
<연습문제 4-1>
declare
v_annsal employees.salary%type;
v_eid employees.employee_id%type := &eid;
begin
select salary*12+nvl(commission_pct,0)*salary*12
into v_annsal
from employees
where employee_id = v_eid;
dbms_output.put_line(to_char(v_annsal,'$999,999,999,00'));
end;
<연습문제 4-2 a,b>
SQL>define b_dname=Education
SQL>define b_dname << 디파인 되었는지 확인
ed
declare
max_deptid departments.department_id%type;
begin
select MAX(department_id)
into max_deptid
from departments;
insert into departments
values (max_deptid+10, &b_dname, null ,null);
dbms_output.put_line(max_deptid)
end;
<연습문제 4-3>
declare
max_deptid departments.department_id%type;
v_result varchar2(100);
begin
select MAX(department_id)
into max_deptid
from departments;
insert into departments
values (max_deptid+10, '&b_dname', null, null);
v_result := sql%rowcount || 'row inserted';
dbms_output.put_line(v_result);
end;
/
<연습문제 4-4>
declare
max_deptid departments.department_id%type;
v_result varchar2(100);
begin
select max(department_id)
into max_deptid
from departments;
update departments
set location_id=1700 where department_id=max_deptid;
v_result := sql%rowcount ||'1 row updated';
dbms_output.put_line(v_result);
end;
/
'개발언어 > PL SQL' 카테고리의 다른 글
해석해보기 (0) | 2018.03.30 |
---|---|
SQL 연습 문제 (0) | 2018.03.30 |
180328 반복문 IF WHILE FOR CONTINUES, 5장 연습문제 (0) | 2018.03.28 |
180327 입력한 사원번호에 해당하는 사원 연봉계산 (0) | 2018.03.27 |
180326 사원번호 입력 받아서 부서 번호 출력하기 (0) | 2018.03.26 |