oracle 之 for循環表


 

代碼

create table tm_lzh as
SELECT 'a1' c1,'b1' c2 FROM dual
union all
SELECT 'a2' c1,'b2' c2 FROM dual
union all
SELECT 'a3' c1,'b3' c2 FROM dual
union all
SELECT 'a4' c1,'b4' c2 FROM dual
union all
SELECT 'a5' c1,'b5' c2 FROM dual
union all
SELECT 'a6' c1,'b6' c2 FROM dual;

DECLARE
a varchar2(10);
b varchar2(10);
begin
for i in(select c1,c2 from tm_lzh) loop
    a:=i.c1;
    b:=i.c2;
    dbms_output.put_line('i.c1='||i.c1);
    dbms_output.put_line('i.c2='||i.c2);
    dbms_output.put_line('a='||a);
    dbms_output.put_line('b='||b);
  end loop;
end;

執行結果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM