Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exception too many rows...

amardeep.sidhuOct 27 2006 — edited Oct 27 2006
Hi

I am getting two different outputs with following code depending upon i declare the variable in first or second way...

when i declare the variable v_empno as number(10) and too many rows exception is raised....and after that i dbms this variable..it is null...

but when i declare the same variable as table.column%type....and the similar scenario happens and i dbms the value of variable...it is not null...rather the first value from output of the query...

declare
--v_empno number(10);
v_empno emp.empno%type;
begin
dbms_output.put_line('before '||v_empno );
select empno into v_empno from emp;
dbms_output.put_line('first '||v_empno);
exception when too_many_rows then
dbms_output.put_line('second '||v_empno);
dbms_output.put_line('exception'||sqlerrm);
end;

is there any specific reason for this....
ur comments plz

Thanks
Sidhu
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2006
Added on Oct 27 2006
7 comments
21,162 views