diff --git a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radb/sql/add_functions_and_triggers.sql b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radb/sql/add_functions_and_triggers.sql index 20128071e8dcfd3cf150cf2b18f0e4464b2a54d4..e882b2c8548e1844cbf52a62ed7d211a40f43a98 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radb/sql/add_functions_and_triggers.sql +++ b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radb/sql/add_functions_and_triggers.sql @@ -19,6 +19,7 @@ DECLARE task_aborted_status_id int := 1100; --beware: hard coded instead of lookup for performance BEGIN IF NEW.status_id <> OLD.status_id THEN + RAISE NOTICE 'on_task_updated: updating task id=% from status % to %', NEW.id, OLD.status_id, NEW.status_id; IF NEW.status_id = task_scheduled_status_id AND OLD.status_id <> task_prescheduled_status_id THEN -- tasks can only be scheduled from the prescheduled state RAISE EXCEPTION 'Cannot update task status from % to %', OLD.status_id, NEW.status_id; @@ -818,6 +819,7 @@ BEGIN IF TG_OP = 'INSERT' OR (TG_OP = 'UPDATE' AND (OLD.status_id <> NEW.status_id)) THEN IF NEW.status_id = claim_conflict_status_id THEN --if claim status went to conflict, then set the task status to conflict as well + RAISE NOTICE 'after_claim_insertupdatedelete: updating task id=% to conflict status % because there are claims in conflict for this task', NEW.task_id, task_conflict_status_id; UPDATE resource_allocation.task SET status_id=task_conflict_status_id WHERE id=NEW.task_id AND status_id <> task_conflict_status_id; ELSIF NEW.status_id = claim_tentative_status_id THEN IF NOT EXISTS (SELECT id FROM resource_allocation.resource_claim @@ -827,10 +829,11 @@ BEGIN IF NOT EXISTS (SELECT id FROM resource_allocation.task WHERE id = NEW.task_id AND status_id = task_approved_status_id) THEN - RAISE NOTICE 'Updating task id=% to approved status % because there are no more claims in conflict for this task', NEW.task_id, task_approved_status_id; + RAISE NOTICE 'after_claim_insertupdatedelete: updating task id=% to approved status % because there are no more claims in conflict for this task', NEW.task_id, task_approved_status_id; -- update tasks which were in conflict, but which are not anymore due this claim-update to the approved status UPDATE resource_allocation.task SET status_id=task_approved_status_id WHERE id=NEW.task_id AND status_id = task_conflict_status_id; + RAISE NOTICE 'after_claim_insertupdatedelete: updated task id=% to approved status % because there are no more claims in conflict for this task', NEW.task_id, task_approved_status_id; END IF; END IF; END IF;