I'm practising/relearning PL/SQL Programming. Trying to retrieve some columns using %ROWTYPE.
Using %TYPE I could select the desired columns but using %ROWTYPE I'm getting error
I think it is crazy to write proc for select * from emp. But, I thought of to test it with a procedure.
Getting this error
>> ORA-01422: exact fetch returns more than requested number of rows
Could you please correct me where I'm doing wrong.
Code: Select all
create or replace procedure tim_empinfo as l_obj emp%ROWTYPE; CURSOR c_obj IS SELECT * FROM emp; rec_cur_row c_obj%rowtype; begin select * into l_obj from emp; open c_obj; loop fetch c_obj into rec_cur_row; exit when c_obj%notfound; end loop; close c_obj; for cur_rec in (select * from emp) loop null; dbms_output.put_line('employee no ' || l_obj.empno); dbms_output.put_line('the name of employee is:' || l_obj.ename); dbms_output.put_line('job of the employee is:' || l_obj.job); dbms_output.put_line('salary of employee is:' || l_obj.sal); end loop; end tim_empinfo; /