Thursday 10 October 2013

Trigger to put certain users jobs in a slow queue


Do you have certain users clogging the system with their crazy jobs?  Consultants causing production to slow down?  Well, implement this simple solution to force their jobs to goto another dedicated queue, in this case Q812.

Note that this is only going to run if the job has been put into the default queue (won't override QSINGLE for example), also it only fires when the job is being moved from S to W.

Note that I set up a UDC to control this functionality, '55', 'JQ' and I also used a public synonym for F0005, as you see there is no owner in the text.

BEFORE UPDATE
ON SVM812.F986110 FOR EACH ROW
DECLARE
  chgFlag NUMBER ;
BEGIN
  IF ltrim(rtrim(:new.jcjobque)) = 'QBATCH' and
ltrim(rtrim(:new.jcjobsts)) = 'S' and ltrim(rtrim(:old.jcjobsts)) = 'W' THEN
    SELECT COUNT(*) INTO chgFlag
    FROM F0005
    WHERE drsy = '55'
    AND drrt = 'JQ'
    AND ltrim(rtrim(drky)) = ltrim(rtrim(:NEW.JCUSER)) ;
    IF chgFlag > 0 THEN
      :new.JCJOBQUE := 'Q812';
    END IF;
  END IF;

No comments: