The below SQL query will remove the duplicate items added by UPDATESTATS for unattended ABEND jobs:
alter session set current_schema=maestro_DB_user;
SELECT count(*) FROM (SELECT DISTINCT AJS_NAME, AJB_NAME, JHR_START_TIME, JHR_RUN_DATE,
JHR_TOTAL_ELAPSED_TIME,JHR_STATUS, WKC_NAME FROM JHR_JOB_HISTORY_RUNS
WHERE jhr_run_date>=trunc(sysdate-12) AND jhr_run_date <trunc(sysdate+1))
WHERE (AJB_NAME like 'MAKEPLAN')
Also if you want to see only the unique jobs that ran on a specific workstation:
alter session set current_schema=maestro_DB_user;
SELECT count(*) FROM (SELECT UNIQUE AJB_NAME FROM (SELECT DISTINCT AJS_NAME, AJB_NAME, JHR_START_TIME,
JHR_RUN_DATE, JHR_TOTAL_ELAPSED_TIME , JHR_STATUS, WKC_NAME FROM JHR_JOB_HISTORY_RUNS
WHERE jhr_run_date>=trunc(sysdate-12) AND jhr_run_date <trunc(sysdate+1))
WHERE (WKC_NAME like 'TWSMASTER'))
And a nice report containing all job runs, all success runs, all ABEND / CANCEL ones, unique jobs success and unique jobs failed:
alter session set current_schema=maestro_DB_user;
SELECT
Count (CASE WHEN JHR_STATUS = 'S' or JHR_STATUS = 'A'
or JHR_STATUS = 'C' THEN '1' ELSE NULL END) All_Job_Runs,
Count (CASE WHEN JHR_STATUS = 'S' THEN '1' ELSE NULL END) All_Runs_Sucessful,
Count (CASE WHEN JHR_STATUS = 'A' or JHR_STATUS = 'C' THEN '1' ELSE NULL END) All_Runs_Failed,
Count (DISTINCT CASE WHEN JHR_STATUS = 'S' THEN AJB_NAME ELSE NULL END) Unique_Jobs_Successful,
Count (DISTINCT CASE WHEN JHR_STATUS = 'A'
or JHR_STATUS = 'C' THEN AJB_NAME ELSE NULL END) Unique_Jobs_Failed
FROM (select distinct AJS_NAME, AJB_NAME, JHR_START_TIME, JHR_RUN_DATE, JHR_TOTAL_ELAPSED_TIME,
JHR_STATUS, WKC_NAME from JHR_JOB_HISTORY_RUNS
WHERE jhr_run_date>=trunc(sysdate-12) AND jhr_run_date <trunc(sysdate+1));
Hint: Modify sysdate-+XX to adjust the number of days on which the reports are ran, also you can use dates as:
jhr_run_date>=TO_DATE('10/03/2012','dd/mm/yyyy') AND jhr_run_date <TO_DATE('12/03/2010','dd/mm/yyyy')
This comment has been removed by the author.
ReplyDeleteHi Radu,
ReplyDeleteall success runs, all ABEND / CANCEL ones, unique jobs success and unique jobs failed: sql query is not working....Im using 8.5.1....Also do you have sql query for Carry forward report also...
Hi Vinay,
DeleteWhat error do you get?
I've test it and it works on 8.3 and 8.6.
im running below query:
DeleteSELECT
Count (CASE WHEN JHR_STATUS = 'S' or JHR_STATUS = 'A'
or JHR_STATUS = 'C' THEN '1' ELSE NULL END) All_Job_Runs,
Count (CASE WHEN JHR_STATUS = 'S' THEN '1' ELSE NULL END) All_Runs_Sucessful,
Count (CASE WHEN JHR_STATUS = 'A' or JHR_STATUS = 'C' THEN '1' ELSE NULL END) All_Runs_Failed,
Count (DISTINCT CASE WHEN JHR_STATUS = 'S' THEN AJB_NAME ELSE NULL END) Unique_Jobs_Successful,
Count (DISTINCT CASE WHEN JHR_STATUS = 'A'
or JHR_STATUS = 'C' THEN AJB_NAME ELSE NULL END) Unique_Jobs_Failed
FROM (select distinct AJS_NAME, AJB_NAME, JHR_START_TIME, JHR_RUN_DATE, JHR_TOTAL_ELAPSED_TIME,
JHR_STATUS, WKC_NAME from JHR_JOB_HISTORY_RUNS
WHERE jhr_run_date>=trunc(02/02/2015-12) AND jhr_run_date <trunc(02/02/2015+1));
and error is:
AWSUI0331E An internal error has occurred.. The SQL query could not be validated. The database internal message is:
ORA-00911: invalid character
Hi Vinay,
DeleteYou are using the query date format wrong:
trunc(02/02/2015-12) AND trunc(02/02/2015+1));
It should be:
trunc(sysdate-12) AND trunc(sysdate+1)); --sysdate is the OS date
or:
TO_DATE('10/02/2015','dd/mm/yyyy') AND TO_DATE('04/03/2015','dd/mm/yyyy'));
Its working now...thanks for your help
DeleteHello Radu,
ReplyDeleteLearnt so many things from your blogs. Are you going to post another blog? How about managing WAS for TWS?
Hi Vinay,
DeleteYes, i plan to post more "hints" and "how to" but i am very busy at the moment.
Also any suggestion on which you need more clarification or you face any issues is welcome :-).