PL/SQLを学んでいます。従業員名を表示するために、カーソルとネストされたテーブルを使用して以下の手順を記述しました。
create or replace procedure
employees_data
is
cursor c1 is select * from employees;
type empl_tbl is table of c1%rowtype;
emp_data empl_tbl;
begin
open c1;
LOOP
fetch c1 bulk collect into emp_data limit 100;
exit when sql%notfound;
for i in 1..emp_data.last
loop
dbms_output.put_line ('employee name is : ' || to_char(emp_data(i).first_name));
end loop;
end loop;
close c1;
end employees_data;
エラーなしでコンパイルされます。手順を実行すると、すべての従業員の名前を表示できます。ただし、データを表示する前に以下のエラーがスローされます。誰でも私を助けてくれますか?
Error starting at line : 1 in command -
exec employees_data()
Error report -
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "HR.EMPLOYEES_DATA", line 12
ORA-06512: at line 1
06502. 00000 - "PL/SQL: numeric or value error%s"
*Cause: An arithmetic, numeric, string, conversion, or constraint error
occurred. For example, this error occurs if an attempt is made to
assign the value NULL to a variable declared NOT NULL, or if an
attempt is made to assign an integer larger than 99 to a variable
declared NUMBER(2).
*Action: Change the data, how it is manipulated, or how it is declared so
that values do not violate constraints.
前もって感謝します。