I'm working on Oracle Apex 5, and when I try to run the application with the following code for a column I get an error saying "exact fetch returns more than requested number of rows"
DECLARE
Num VARCHAR2(40);
BEGIN
SELECT CONCAT(YEAR, '-')
INTO Num FROM APPS;
END;
The variable terranumber can hold only one value. So, if you select query returns multiple rows, it is going to throw this error.
If you want any one of the values:
declare
terranumber varchar2(40);
begin
select concat(year, '-') into terranumber
from mp_applications
where rownum = 1;
end;
/
Perhaps you want to get max
(or min
) of year:
declare
terranumber varchar2(40);
begin
select concat(max(year), '-') into terranumber
from mp_applications;
end;
/
Or may be you want to access all the values one by one:
begin
for rec in (select concat(year, '-') as year from mp_applications)
loop
-- use rec.year as required
end loop;
end;
/