adding begin end dates to instructions

parent 5e8dadf3
......@@ -89,7 +89,9 @@ thisTrigger: BEGIN
NOW(3)
)
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id;
END;;
--
-- It deletes current try for a given session
DROP PROCEDURE IF EXISTS deleteOpenTry;
......@@ -117,6 +119,7 @@ AFTER INSERT ON working_session
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE ins_begin DATE;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
......@@ -125,9 +128,25 @@ thisTrigger: BEGIN
LEAVE thisTrigger;
END IF;
UPDATE instruction
SET status='started'
WHERE id=new.id_ins;
SELECT begin INTO ins_begin
FROM instruction
WHERE id = NEW.id_ins
IF (ins_begin IS NULL) THEN
UPDATE instruction
SET
begin = NOW(3),
end = NOW(3)
WHERE
id = NEW.id_ins
END IF;
UPDATE instruction
SET
status='started',
end = NOW(3)
WHERE
id = NEW.id_ins;
INSERT INTO try(`id_ws`)
VALUES (new.id);
......@@ -150,6 +169,16 @@ thisTrigger: BEGIN
LEAVE thisTrigger;
END IF;
-- end date for related instruction is updated
IF (OLD.end < NEW.end) THEN
UPDATE instruction
SET
end = NEW.end
WHERE
id = NEW.id_ins
END IF;
-- remove open try
IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id);
END IF;
......@@ -335,6 +364,8 @@ thisTrigger: BEGIN
WHERE id = NEW.id_ws;
END IF;
END;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment