为什么我会收到以下错误?
Error starting at line 1 in command:
select FUNC from dual
Error report:
SQL Error: ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "ANONYMOUS.FUNC", line 15
14551. 00000 - "cannot perform a DML operation inside a query "
*Cause: DML operation like insert, update, delete or select-for-update
cannot be performed inside a query or under a PDML slave.
*Action: Ensure that the offending DML operation is not performed or
use an autonomous transaction to perform the DML operation within
the query or PDML slave.
功能:
create or replace function FUNC
return types.ref_cursor
AS
result_set types.ref_cursor;
alarm ofalarmmessages.ALARMID% TYPE;
username ofalarmmessages.USERNAME% TYPE;
alarmmsg ofalarmmessages.ALARMMESSAGE% TYPE;
dvice ofalarmmessages.DEVICEID% TYPE;
begin
OPEN result_set FOR
SELECT USERNAME,ALARMID,ALARMMESSAGE,DEVICEID
FROM ofalarmmessages where newoldflag='N';
LOOP
FETCH result_set into username,alarm,alarmmsg,dvice;
update ofalarmmessages set newoldflag ='Y' where alarmid= alarm;
END LOOP;
RETURN result_set;
CLOSE result_set;
END;
/
show errors;