gpt4 book ai didi

mysql - 将 BULK COLLECT 与 LIMIT 子句结合使用

转载 作者:行者123 更新时间:2023-11-29 19:42:36 27 4
gpt4 key购买 nike

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

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;

显示错误:错误(23,5):PLS-00306:调用“PUT_LINE”时参数数量或类型错误

in 
dbms_output.put_line(l_test_departments(i));

请回答

最佳答案

“l_test_departments”是保存记录的“test_departments_aat”类型的数组。由于其类型为“test_departments_cur%rowtype”,因此要访问游标的值,您需要传递游标的列,如下所示:

 dbms_output.put_line(l_test_departments(i).<column_name>);

希望这有帮助。

关于mysql - 将 BULK COLLECT 与 LIMIT 子句结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41259279/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com