-------------------------------------------------1111111111111111
declare
v_nh1 lfsgt330.coop%TYPE;
v_nh2 lfsgt330.io_slip%TYPE;
v_nh3 lfsgt330.slip_dt%TYPE;
v_nh4 lfsgt330.slip_no%TYPE;
v_nh5 lfsgt330.cust_cd%TYPE;
v_nh6 lfsgt330.car_no%TYPE;
v_nh7 lfsgt330.class%TYPE;
CURSOR lfsgt331_cursor is
select a.coop as coop,
a.io_slip as io_slip,
a.slip_dt as slip_dt,
a.slip_no as slip_no,
a.cust_cd as cust_cd,
a.car_No as car_no,
a.class as class
from lfsgt331 a , lfsgt320 b, lfsgt321 c
where a.io_slip=b.io_slip
and a.coop=b.coop
and b.coop=c.coop
and a.slip_dt=b.slip_dt
and a.slip_no=b.slip_no
and b.io_slip=c.io_slip
and b.slip_dt=c.slip_dt
and b.slip_no=c.slip_no
and c.item_cd in ('113112','122112','122712','124112','124312','122312','122912','425432',
'425632','342412','414312','414422','341422','351322','342342','361432','331312','341512')
and a.slip_dt between '19900101' and '19991231'
;
BEGIN
OPEN lfsgt331_cursor;
LOOP
FETCH lfsgt331_cursor INTO v_nh1,v_nh2,v_nh3,v_nh4,v_nh5,v_nh6,v_nh7;
EXIT WHEN lfsgt331_cursor%NOTFOUND;
if v_nh5 = v_nh6 then
update lfsgt331 set cust_cd='87680000',
car_no= '87680000'
where
v_nh1 = coop and
v_nh2 = io_slip and
v_nh3 = slip_dt and
v_nh4 = slip_no and
v_nh5 = cust_cd and
v_nh6 = car_no and
v_nh7 = class;
else
update lfsgt331 set car_no= '87680000'
where
v_nh1 = coop and
v_nh2 = io_slip and
v_nh3 = slip_dt and
v_nh4 = slip_no and
v_nh5 = cust_cd and
v_nh6 = car_no and
v_nh7 = class;
end if;
END LOOP;
CLOSE lfsgt331_cursor;
end;
----------------------------------------------------2222222222222
|