I am having a tough time understanding what is wrong with my pl/sql trigger. The error is : Error report - SQL Error: ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at "SYSTEM.TRG_LATE_RETURN", line 6 ORA-04088: error during execution of trigger 'SYSTEM.TRG_LATE_RETURN' 01422. 00000 - "exact fetch returns more than requested number of rows" *Cause: The number specified in exact fetch is less than the rows returned. *Action: Rewrite the query or change number of rows requested
My trigger is as follows:
create or replace trigger trg_late_return
before update of DETAIL_RETURNDATE, DETAIL_DUEDATE on TY_DETAILRENTAL
declare
temp_date DATE:= SYSDATE;
temp_due_date DATE:= SYSDATE;
BEGIN
select DETAIL_RETURNDATE
into temp_date
from TY_DETAILRENTAL;
select DETAIL_DUEDATE
into temp_due_date
from TY_DETAILRENTAL;
IF temp_date is null
THEN
update TY_DETAILRENTAL
set DETAIL_DAYSLATE=null;
END IF;
if temp_date <> null
THEN
if temp_date = trunc(temp_due_date) + 1
then
update TY_DETAILRENTAL
set DETAIL_DAYSLATE=0;
end if;
if temp_date > trunc(temp_due_date) + 1
then
update TY_DETAILRENTAL
set DETAIL_DAYSLATE = DETAIL_RETURNDATE - DETAIL_DUEDATE;
end if;
end if;
END;
/
New to SQL and PL/SQL so I would appreciate any help.
TY_DETAILRENTALhas exactly one row, so yourselect . . . intostatements are not going to work. - Gordon Linoff