Exact fetch return more than requested number of rows
Posted on 2006-06-13
I have the following PL/SQL code which I am trying to test by copying and pasting it next to the SQL prompt. I want to obtain all the distinct termcodes from three years up to the value in end_term.
set serveroutput on size 9999999999999999;
end_term := '200601';
select distinct termcode into term from student where termcode between to_char(to_number(end_term)-300) and end_term;
However, I obtain the following error:
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 10
How do I fix it?