cancel
Showing results for 
Search instead for 
Did you mean: 

removing duplicate job names in the report

Former Member
0 Kudos

Hi All,

I could not remove duplicates in the report using the below query.

select Job.* from Job where JobDefinition in(select JobDefinition.UniqueId from JobDefinition where JobDefinition.BranchedLLPVersion = "+MASTER+") and Job.status in ('K','E') order by Job.RunStart;

Right now I am getting both the child job name and parent job name as same if there is error in the child jobs. I want only parent job name even there are more than one child job errors.

Please help me to get the report.

Accepted Solutions (0)

Answers (2)

Answers (2)

gmblom
Active Contributor
0 Kudos

Hello,

You can easily just remove the steps from the query. Also, the whole 'master' check is not necessary here.

select Job.* from Job where Job.JobChainStep is null and Job.status in ('K','E') order by Job.RunStart

Regards Gerben

Former Member
0 Kudos

Hi Gebren,

I got error while executing. I have attached the error log and the code as well. Could you pls help me.

h_carpenter
Active Contributor
0 Kudos

Hi vishnu,

There is one error:

select Job.* from Job where Job.JobChainStep is null and Job.Status in ('K','E') order by Job.RunStart

instead of

select Job.* from Job where Job.JobChainStep is null and Job.status in ('K','E') order by Job.RunStart

How did I get to this conclusion ?

When I have a Java stack, I always first look at the "caused by" lines ... and here, I see :

Caused by: com.redwood.scheduler.persistence.api.PersistenceException$UnknownField: JCS-XXXXX: Unknown field status in Job debug:  aliases=true {Job=Job}

So, I looked at the data model for Job and I saw that the column is named Status, not status. The important part here is "Unknown field status in Job".

Regards,

HP

h_carpenter
Active Contributor
0 Kudos

Hi Vishnu,

The following is not necessary:

DateTimeZone startTime = jcsJob.getJobParameterByName("DATE_START").getInValueDate();

DateTimeZone endTime = jcsJob.getJobParameterByName("DATE_END").getInValueDate();

You can simply use DATE_START and DATE_END in your source, as in RedwoodScript jobs, the job parameters are declared as such for you.

In your code, you can safely remove those two lines, since you are using Gerben's SQL query (with Job.Status instead of Job.status).

Regards,

HP

Former Member
0 Kudos

Hi Carpetner,

Thanks a ton..it is working fine..

nanda_kumar21
Active Contributor
0 Kudos

You have to check where clause on JobDefinitionType for JobChain.

select Job.* from Job where JobDefinition in(select jd.UniqueueId from JobDefinition jd where jd.JobDefinitionType = (select jdt.UniqueId from JobDefinitionType jdt where jdt.Name = 'JOB_CHAIN')) and Job.status in ('K','E') order by Job.RunStart;

This will retrieve only job chains, but in case you have an indvidual job that is not part of a job chain, it will not be returned.

I would recommend getting all the jobs in an iterator(both job chains and the  child jobs), and then

Job j = it.next();

while(j.getParentJob() != null)

{

  j = j.getParentJob();

}

//print the output you want.

Thanks

Nanda

Former Member
0 Kudos

Hi Nanda,

thanks..but I want only parent job chain name and also the individual jobs. I have used the code but is throwing error.

incomparable types if(jobTemp.getParentJob()!=null)

nanda_kumar21
Active Contributor
0 Kudos

is your jobTemp Job or Job Definition?

also, please past the error stack trace.

Thanks

Nanda

Former Member
0 Kudos

Hi Nanda,

I have attached the code and error stack.

I have commented the query which I used before. Also I have added if(parentjob==null).