geeta_m9
asked on
Exact fetch return more than requested number of rows
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;
declare
end_term varchar2(8);
term varchar2(8);
begin
end_term := '200601';
select distinct termcode into term from student where termcode between to_char(to_number(end_term )-300) and end_term;
dbms_output.put_line(term) ;
end;
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?
set serveroutput on size 9999999999999999;
declare
end_term varchar2(8);
term varchar2(8);
begin
end_term := '200601';
select distinct termcode into term from student where termcode between to_char(to_number(end_term
dbms_output.put_line(term)
end;
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It works now, thanks!
ASKER
ERROR at line 14:
ORA-06550: line 14, column 30:
PLS-00302: component 'TERM' must be declared
ORA-06550: line 14, column 3:
PL/SQL: Statement ignored