create or replace procedure pro_test  
  as
cursor my_cursor is select user_id,user_name,user_pass from tb_users;
  v_users tb_users%rowtype;
begin
  open my_cursor;
loop
  fetch my_cursor into v_users;
  exit when my_cursor%notfound;
  dbms_output.put_line(v_users.user_id||'  '||v_users.user_name||'  '||v_users.user_pass);
end loop;
close my_cursor;
end;
/
set serveroutput on
begin
pro_test;
end;
/

解决方案 »

  1.   

    语法结构有错误
    应去掉Declare
    正确如下:create or replace procedure pro_test  
    as
      cursor my_cursor is select user_id,user_name,user_pass from tb_users;
      v_users tb_users%rowtype;
    begin
      open my_cursor;
    loop
      fetch my_cursor into v_users;
      dbms_output.put_line(v_users.user_id||'  '||v_users.user_name||'  '||v_users.user_pass);
    end loop;end;
      

  2.   

    sorry,改一改create or replace procedure pro_test  
      as
    cursor my_cursor is select user_id,user_name,user_pass from tb_users;
      v_users my_cursor%rowtype;--此处改为游标类型
    begin
      open my_cursor;
    loop
      fetch my_cursor into v_users;
      exit when my_cursor%notfound;
      dbms_output.put_line(v_users.user_id||'  '||v_users.user_name||'  '||v_users.user_pass);
    end loop;
    close my_cursor;
    end;
    /