I am learning PL/SQL. I have written the procedure below using cursor and nested table to display employee names.
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;
It compilesd without any errors. When I am executing the procedure, I am able to display all the employees names. But, the below error is thrown before displaying data. Can anyone please help me out of this?
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.
Thanks in advance.