create or replace procedure test As
Cursor cur1 Is Select townname From town;
Name Varchar2(20);
Begin  For Name In cur1 Loop
  Begin
  dbms_output.put_line(Name);
  End;
  End Loop;
end test;

解决方案 »

  1.   


    For Name In cur1 Loop
      Begin  --此处去掉
      dbms_output.put_line(Name);
      End;   --此处去掉
      End Loop;
      

  2.   

    还是报错:pls-00306:wrong number or types of arguments ini call to 'pub_line'
      

  3.   

    dbms_output.put_line(Name.townname );
    另外,不需要声明 Name Varchar2(20);
    实际在 for 循环中,你使用的 Name 是一个记录集对象,不是你声明的字符串变量