cancel
Showing results for 
Search instead for 
Did you mean: 

executeQuery()

Former Member
0 Kudos

Hi,

String query = "select job.JobDefinition from Job where job.JodId = '4990941' ";

jcs,outprint("query is"+query);

jcssession.executeQuery(query,null,long object);

I could get the query printed.

but I am getting the error in the nextline.

please find the attached error log.

Accepted Solutions (1)

Accepted Solutions (1)

nanda_kumar21
Active Contributor
0 Kudos

What error are you getting?

thanks

Nanda

Former Member
0 Kudos

I have attached the error log.

gmblom
Active Contributor
0 Kudos

Hi,

What is it that you try to achieve here. Will this code be part of a bigger application? Based on these few lines there is very little we can say.

If you are really looking into adding functionality using RedwoodScript I would suggest to take a course on either RedwoodScript or Java.

Regards Gerben

h_carpenter
Active Contributor
0 Kudos

Hi Vishnu,

As Gerben says, we cannot say from your code snippet which, as I had pointed out in the other thread, contains typos. This is certainly NOT the code that caused that error - you will not be able to save the above code in a job definition editor.

Please copy & paste the actual code you are using, preferably all of it, not just the snippet where an error occurs.

Besides, why are you using "long object" as a APIResultSetCallback ? Please see the example in the API documentation for using jcsSession.executeQuery().

You should consider jcsSession.executeObjectQuery(); that one does not need an APIResultSetCallback and is easier to handle.

Regards,

HP

Former Member
0 Kudos

Hi All,

My scenario is this.

I will pass jobId as parameter and get the status of that job. Once I get the status, I will update an user-defined table.

I am executing this script in shell as of now by hard-coding jobId in the query.

String query = "select job.JobDefinition from Job where job.JodId = '4990941' ";

jcs,outprint("query is"+query);

I am confused here whether to use executeQuery or executeObjectQuery. As I know that the result is 1, I thought of using executeQuery instead of objectQuery.

jcssession.executeQuery(query,null,long object);

but I am getting the error at this line. Please help

h_carpenter
Active Contributor
0 Kudos

Hi Vishnu,

There are multiple typos in your query. If you want to get the job status, you should consider REL:

Two parameters, one of type Number named JOBID, holding your job id, the other, of type String, holding the following default value:

=Query.getString('select Job.Status from Job where Job.JobId=?', [parameters.JOBID])

This will give you the Status code.

For the record, this is how you use executeQuery, provided your query returns Long's (which is the case here) - note that I highly recommend using the above, much easier:

Here is an example using LongCallBack.

{

  //Comment out the following line in your job definition

  //create a parameter named MyParameter on the job definition

  String MyParameter = "123";

  final LongCallBack callback = new LongCallBack(0);

  final String QUERY = "select Job.JobDefinition from Job where Job.JobId = ?";

  jcsSession.executeQuery(QUERY, new Object[] { new Long(MyParameter) }, callback);

  final java.util.List resultWithUniqueIds = callback.getResult();

  for (final Iterator itr = resultWithUniqueIds.iterator(); itr.hasNext();)

   {

     final Long jobDefinitionUniqueId = (Long) itr.next();

     //... your code here

     jcsOut.println(jobDefinitionUniqueId);

   }

}

Regards,

HP

Former Member
0 Kudos

Hi HP,

I am getting index out of bounds exception.

h_carpenter
Active Contributor
0 Kudos

Hi Vishnu,

Have you created a parameter named MyParameter on the job definition and assigned it the value of a valid job id ?

What is the value of the parameter on the failed job.

Regards,

HP

Former Member
0 Kudos

Thanks HP,

it worked. my bad I didn't create parameter.

Answers (0)