-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcusor_fetch.sql
More file actions
38 lines (31 loc) · 810 Bytes
/
cusor_fetch.sql
File metadata and controls
38 lines (31 loc) · 810 Bytes
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
32
33
34
35
36
37
38
set serveroutput on
set verify off
declare
cursor mycur is select sapay, sabun from sawon;
v_sapay sawon.sapay%type;
v_sabun sawon.sabun%type;
v_comm sawon.comm%type;
begin
if mycur%isopen then close mycur;
end if;
open mycur;
loop
fetch mycur into v_sapay, v_sabun;
exit when (mycur%notfound);
if v_sapay < 1000 then
v_comm := v_sapay*0.1;
elsif v_sapay <= 2000 then
v_comm := v_sapay*0.15;
elsif v_sapay > 2000 then
v_comm := v_sapay*0.2;
else
v_comm := 0;
end if;
update sawon
set comm = v_comm
where sabun = v_sabun;
dbms_output.put_line('»ç¹ø: ' || v_sabun || ', Ä¿¹Ì¼Ç: ' || v_comm);
end loop;
close mycur;
end;
/