这段时间实在是很忙,结婚、赶项目进度、被迫出书、教学。每件事都是不能得罪的。。。。
前几天帮教务处修正oracle数据库数据问题,把代码贴出来防止以后找不到了
declare
CURSOR
curTTT
is
select
XN,XM,XQ,KCMC,XF,BJMC
from
CJB;
XN1
VARCHAR2
(
10
);
XM1
VARCHAR2
(
20
);
XQ1
NUMBER
(
1
);
KCMC1
VARCHAR2
(
40
);
XF1
VARCHAR2
(
10
);
BJMC1
VARCHAR2
(
40
);
begin
--
---------------------------------------
if
curTTT
%
isopen
=
false
then
open
curTTT;
end
if
;
fetch
curTTT
into
XN1,XM1,XQ1,KCMC1,XF1,BJMC1;
--
Dbms_Output.put('1');
while
curTTT
%
found
loop
if
XF1
=
'
0
'
then
update
CJB
set
XF
=
(
select
*
from
(
select
nvl(XF,
0
)
from
CJB
where
BJMC
=
BJMC1
and
KCMC
=
KCMC1
and
XQ
=
XQ1
and
XN
=
XN1
and
XF
>
'
0
'
)
where
ROWNUM
<=
1
)
where
BJMC
=
BJMC1
and
KCMC
=
KCMC1
and
XQ
=
XQ1
and
XN
=
XN1
and
XM
=
XM1;
end
if
;
![None.gif](/Images/OutliningIndicators/None.gif)
if
curTTT
%
rowcount
=
0
then
exit
;
end
if
;
![None.gif](/Images/OutliningIndicators/None.gif)
fetch
curTTT
into
XN1,XM1,XQ1,KCMC1,XF1,BJMC1;
end
loop;
![None.gif](/Images/OutliningIndicators/None.gif)
commit
;
close
curTTT;
--
------------------------------------------
end
;