pl/sql用for in和for select into循環遍歷表


create or replace procedure test_procedure_job

as
v1 varchar2(50);
v2 varchar2(50);
v3 varchar2(50);
begin
   for v1 in
   (select t.id
          from test_table t) 
   loop
       select t.username,t.password into v2,v3 from sshtest t where t.id = v1.id;
       
       dbms_output.put_line(v1.id || ',' || v2 || ',' || v3);
     
   end loop;
   
end test_procedure_job;

 

原來,for in 取出來的v1,是一個虛表。里面有一個屬性id。

所以在循環里面,不是用v1,而是用v1.id。試了很久,郁悶。

然后,循環里面,用了select into。直接用v2,v3。真神奇。

這里竟然和v1不同。


免責聲明!

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



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