另一種為 pcursor1: for loopcs1 as cousor1 cursor as select market_code as market_code /t from tb_market_code /t for update /tdo /tend for; 這種方式的優點是比較簡單,不用(也不允許)使用open,fetch,close。 但不能使用with hold 選項。如果在游標循環內要使用commit,rollback則不能使用這種方式。如果沒有commit或rollback的要求,推薦使用這種方式(看來For這種方式有問題)。
修改游標的當前記錄的方法 update tb_market_code set market_code='0' where current of cursor1; 不過要注意將cursor1定義為可修改的游標 declare cursor1 cursor for select market_code from tb_market_code for update;
for update 不能和GROUP BY、 DISTINCT、 ORDER BY、 FOR READ ONLY及UNION, EXCEPT, or INTERSECT但 UNION ALL除外)一起使用。
1.5 類似decode的轉碼操作 oracle中有一個函數 select decode(a1,'1','n1','2','n2','n3') aa1 from db2沒有該函數,但可以用變通的方法 select case a1 when '1' then 'n1' when '2' then 'n2' else 'n3' end as aa1 from