Home » SQL & PL/SQL » SQL & PL/SQL » Please help me out
Please help me out [message #197672] Thu, 12 October 2006 04:44 Go to next message
Messages: 15
Registered: September 2006
Location: Tamilnadu
Junior Member

2 v_empno number(4);
3 commission varchar2(20);
4 begin
5 select empno,empname into v_empno,commission from arun
6 where
7 empno=(select max(empno) from arun);
8 insert into arun(empno,empname) values (v_empno,commission);
9 end;
10 /
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 5

thanks & regards,
Re: Please help me out [message #197677 is a reply to message #197672] Thu, 12 October 2006 05:01 Go to previous message
Messages: 381
Registered: September 2006
Location: UK
Senior Member
It means that the

select empno,empname into v_empno,commission from arun
empno=(select max(empno) from arun);

is returning multiple rows i.e. there are two employees with the same (highest) value of empno. Change the select to a cursor and retrieve only the first row(see PL/SQL manual for more details of cursors).
Previous Topic: create a procedure
Next Topic: group function in cursors
Goto Forum:

Current Time: Mon Jul 24 10:05:12 CDT 2017

Total time taken to generate the page: 0.06767 seconds