PLSQL 申明和游标
生活随笔
收集整理的這篇文章主要介紹了
PLSQL 申明和游标
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
--從鍵盤輸入一個數(shù)
accept b prompt '請輸入一個大于零的數(shù)字';
declareanum number := &b;
beginwhile anum>0loopdbms_output.put_line(anum);anum:=anum-1;end loop;
end;declarev_num number;
begin
-- 從stsu表中選出id最大的值,并根據(jù)該值打印次數(shù)select max(id) into v_num from stsu;loopdbms_output.put_line(v_num);v_num := v_num-1;exit when v_num=0;end loop;
end;declarecursor cur is select id,math from stsu;
beginfor cur in (select id,math from stsu)loopdbms_output.put_line(cur.id ||'編號學(xué)員的數(shù)學(xué)分?jǐn)?shù):'||cur.math);end loop;
end;declare cursor cursor_id is select id,math from stsu;v_id stsu.id%type;v_math stsu.math%type;
begin --打開游標(biāo)open cursor_id;loop -- 抓取數(shù)據(jù)fetch cursor_id into v_id,v_math;exit when cursor_id%notfound;dbms_output.put_line(v_id||' '||v_math);end loop;-- 關(guān)閉游標(biāo)close cursor_id;
end;
?
轉(zhuǎn)載于:https://www.cnblogs.com/lantu1989/p/6150384.html
總結(jié)
以上是生活随笔為你收集整理的PLSQL 申明和游标的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xtrabackup迁移单独一张INNO
- 下一篇: 【图像缩放】双立方(三次)卷积插值