CREATE DEFINER="cw"@"%" PROCEDURE "removeTaskById"(v_taskid int)
BEGIN
UPDATE task_pset_props SET value = TRIM(BOTH ';' FROM (select replace(';'||value||';',';'||v_taskid||';',';'))) WHERE NAME='taskid.list';
DELETE FROM task_log WHERE taskid=v_taskid;
DELETE FROM task_status WHERE taskid=v_taskid;
DELETE FROM task_pset_props WHERE taskpsetid in (select taskpsetid FROM task_pset where taskid=v_taskid);
DELETE FROM task_exec_props WHERE taskexecreqid in (select taskexecreqid FROM task_exec_req WHERE taskid=v_taskid);
DELETE FROM task_exec_req WHERE taskid=v_taskid;
DELETE FROM task_pset WHERE taskid=v_taskid;
DELETE FROM task WHERE taskid = v_taskid;
END