MySQL Forums
Forum List  »  Triggers

my first attemp at a trigger
Posted by: paul van zyl
Date: June 02, 2011 10:30AM

We are using Info @ hand and the workflow has a bug.

If you do a workflow in case to create a task, it creates over 500 tasks. thus the reason i am trying this script.

What i am trying to achieve is when case status equels -- to create a task calledd --. but in this script it keeps creating the tasks everytime i edit a case and the status stays the same, or even when i edit the task a new task gets created.
How would i be able to fix this, or does someone know how to fix the info@hand workflow from multiplying.

DELIMITER $$

USE `======`$$

DROP TRIGGER /*!50032 IF EXISTS */ `Cases`$$

CREATE
/*!50017 DEFINER = 'eeeeee'@'localhost' */
TRIGGER `Cases` AFTER UPDATE ON `cases`
FOR EACH ROW BEGIN
INSERT INTO tasks (id,date_entered,date_modified,assigned_user_id,mo dified_user_id,created_by,
NAME,STATUS,date_due_flag,date_start_flag,parent_t ype,parent_id,priority,description)

SELECT MD5(RAND()) AS id,
CURDATE()AS 'd1',

CURDATE() AS 'D2',

assigned_user_id,

modified_user_id,

created_by,

CASE

WHEN STATUS = 'Obtain Info' THEN 'Gather Info'
WHEN STATUS = 'Contact Client' THEN 'Contact Client to get more info'
END AS 'taskname',
'Not Started' AS 'caseSTATUS',
'on' AS 'on121',
'on' AS 'on1',
'Cases' AS 'beantype',
cases.id AS 'Caseid',
'p2' AS 'peep',
CASE
WHEN STATUS = 'Obtain Info' THEN 'Gather all relevant information need to assist the SP'
WHEN STATUS = 'Contact Client' THEN 'Contact Client to get more info'
END AS 'description'
FROM cases
$$
DELIMITER ;

Options: Reply• Quote


Subject
Views
Written By
Posted
my first attemp at a trigger
2713
June 02, 2011 10:30AM
1188
June 02, 2011 11:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.