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
arunprabhu29917
Messages: 15
Registered: September 2006
Location: Tamilnadu
Junior Member

SQL> DECLARE
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 /
DECLARE
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 5


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

select empno,empname into v_empno,commission from arun
where
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: Fri Dec 09 23:00:05 CST 2016

Total time taken to generate the page: 0.14523 seconds