
uj5u.com熱心網友回復:
for x in (select colsfrom xxxxx x
inner join yyyyyyy y on x.id =y.xid
inner join zzzzz z on x.id = z.xid
where x.name in (select name from aaaa where age >1000 and fff > 30000 or (cd > 1000 and tt != 1000))
and exists(select * from bbbb b where x.idx = 1000 and b.id = x.xxid)
and ...
and ...)
loop
// todo
end loop
如果改成這樣,是不是看著回圈體更清爽一些
cursor cur is
select cols
from xxxxx x
inner join yyyyyyy y on x.id =y.xid
inner join zzzzz z on x.id = z.xid
where x.name in (select name from aaaa where age >1000 and fff > 30000 or (cd > 1000 and tt != 1000))
and exists(select * from bbbb b where x.idx = 1000 and b.id = x.xxid)
and ...
and ...;
open cur;
for rec in cur loop
// todo
end loop;
close cur;
uj5u.com熱心網友回復:
兩者一樣的,只是一個顯示定義游標,另一個隱式定義。uj5u.com熱心網友回復:
謝謝哈【笑抽】【笑抽】
uj5u.com熱心網友回復:
但是他問在什么情況下用一,什么情況下用二啊。。。
uj5u.com熱心網友回復:
寫法稍有差別,功能沒什么差別,適用的場景一樣。
第一種更簡潔些。
uj5u.com熱心網友回復:
如果非要說差別,那就是第一種適合游標SQL(SELECT陳述句)簡單些的,第二種更適合游標SQL(SELECT陳述句)更復雜的場景。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/14697.html
標籤:開發
上一篇:求大神oracle存盤程序寫法
