I have the following code, that updates the required date on Project Navigator Demand based on a custom field. It runs fine as a custom menu, but when i run it as an event on creation of a new demand line, it crashes with a mutating trigger error. I believe it’s because I’m selecting info from the table I’m trying to update. Whats the best way to get this to work? TIA.
PROCEDURE Update_ProjMiscDem_ReqdDate(MATR_SEQ_NO_ IN VARCHAR2) IS
attr_ VARCHAR2(1000);
info_ VARCHAR2(1000);
offset_ NUMBER;
objid_ VARCHAR2(1000);
objversion_ VARCHAR2(1000);
CURSOR get_parts IS
SELECT p.objid, p.objversion, p.activity_seq
FROM project_misc_procurement p
WHERE p.matr_seq_no = matr_seq_no_;
BEGIN
info_ := NULL;
OPEN get_parts;
FETCH get_parts INTO objid_, objversion_;
CLOSE get_parts;
offset_ := work_time_calendar_api.Get_Work_Days_Between('*',
activity_cfp.Get_Cf$_Receive_Parts_By(activity_cfp.Get_Objkey(activity_seq_)),
activity_api.Get_Early_Finish(activity_seq_));
CLIENT_SYS.CLEAR_ATTR(attr_);
CLIENT_SYS.ADD_TO_ATTR('OFFSET', offset_, attr_);
PROJECT_MISC_PROCUREMENT_API.Modify__(info_, objid_, objversion_, attr_, 'DO');
COMMIT;
END: