使用BULK COLLECT和LIMIT条款

时间:2016-12-21 09:29:19

标签: mysql

我是初学者....只是想知道为什么以下脚本在编译时会出错。你的回复会很有帮助

create or replace procedure fetch_employee
is 
    cursor test_departments_cur
    is 
      select * from test_departments;

    Type test_departments_aat is
    table of test_departments_cur%ROWTYPE
    INDEX BY PLS_INTEGER;

    l_test_departments test_departments_aat;

 Begin
  open test_departments_cur;
  loop
    fetch test_departments_cur
    bulk collect into l_test_departments limit 10;

    exit when l_test_departments.count=0;

    for i in 1..l_test_departments.count
    loop
    dbms_output.put_line(l_test_departments(i));
    end loop;
    dbms_output.put_line('=============================================');
  end loop;

  close test_departments_cur;
end   fetch_employee;

显示错误:Error(23,5): PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'

in 
 dbms_output.put_line(l_test_departments(i));

请回答

1 个答案:

答案 0 :(得分:0)

" l_test_departments"是一个类型" test_departments_aat"这是一个记录。因为它的类型是" test_departments_cur%rowtype" ,因此要访问游标的值,需要按如下方式传递游标列:

new view

希望这有帮助。