第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么我insert之后就直接掛起了

為什么我insert之后就直接掛起了,需要手動(dòng)commit,后面的語(yǔ)句都不執(zhí)行了


正在回答

1 回答

declare

cursor cdept is select deptno from dept;

pdeptno dept.deptno%type;

cursor cemp(dno number) is select sal from emp where deptno = dno;

psal emp.sal%type;

count1 int;

count2 int;

count3 int;

totalMon number := 0;

flag number;

begin

? open cdept;

? --外層循環(huán)

? loop

? ? fetch cdept into pdeptno;

? ? exit when cdept%notfound;

? ? --判斷部門是否存在,如果部門不存在直接退出所有循環(huán)

? ? select count(1) into flag from emp where deptno = pdeptno;

? ? if flag = 0 then return;

? ? end if;

? ? --第一層循環(huán)內(nèi)給變量賦值為0,保證每次內(nèi)層循環(huán)的計(jì)數(shù)器都從零開(kāi)始(必須要寫(xiě)外層循環(huán)內(nèi),內(nèi)層循環(huán)外)

? ? count1 := 0;

? ? count2 := 0;

? ? count3 := 0;

? ? open cemp(pdeptno);

? ? loop

? ? ? select sum(sal) into totalMon from emp where deptno = pdeptno;

? ? ? fetch cemp into psal;

? ? ? exit when cemp%notfound;

? ? ? if psal <3000 then count1 := count1+1;

? ? ? elsif psal <6000 then count2 := count2+1;

? ? ? else count3 := count3+1;

? ? ? end if;

? ? end loop;

? ? close cemp;

? ? --保存到msg表

? ? insert into msg values(pdeptno,count1,count2,count3,totalMon);

? ? --輸出

? ? --dbms_output.put_line('部門:'||pdeptno||' 3000以下為:'||count1||' 3000-6000為:'||count2||' 6000以上為:'||count3||' 總額為:'||totalMon);

? end loop;

? close cdept;

? commit;

? dbms_output.put_line('統(tǒng)計(jì)完成');

end;

/


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么我insert之后就直接掛起了

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)