4 Replies Latest reply on Sep 17, 2019 5:34 AM by Ilyas Shaikh

    Run a job based on o/p of the Database Query Job

    Avneesh Jain
      Share This:

      Run a job based on o/p of the Database Query Job,

       

      How to handle and run the job if the query returns only 1 Row.

       

      We need to check the same by querying DB everytime and then run the job accordingly.

        • 1. Re: Run a job based on o/p of the Database Query Job
          Bhanu Prakash Badiginchala

          I think SQL normally returns the number of rows in the output. So you can do something like this on the Dtabase query job's actions:

           

          2 of 2 people found this helpful
          • 2. Re: Run a job based on o/p of the Database Query Job
            Ilyas Shaikh

            Hi Avneesh,

             

            You can run the query to get the count and based on count you can take an action on the job.

             

            for an example you can modify your query like below and read the output with specific statement output as shown in screen shot shared by Bhanu Prakash Badiginchala (But I think in statement you need to put * and in code 1)

             

            select count(*) from table where column='value';

             

            Regards,

            Ilyas Shaikh

            1 of 1 people found this helpful
            • 3. Re: Run a job based on o/p of the Database Query Job
              Avneesh Jain

              My query returns as below :

              +-----------+

              |           |

              +-----------+

              |0          |

              +-----------+

               

               

               

               

               

               

               

               

              Job statistics:

              +-------------------------+-------------------------+

              |Start Time               |20190917042109           |

              +-------------------------+-------------------------+

              |End Time                 |20190917042110           |

              +-------------------------+-------------------------+

              |Elapsed Time             |45                       |

              +-------------------------+-------------------------+

              |Number Of Affected Rows  |1                        |

              +-------------------------+-------------------------+

              Exit Code    = 0

              Exit Message = Normal completion

               

              where code looks should be Zero  (0) and  as row returned is also Zero , what could be the On Do action. Can you please suggest??

               

              we need to run the next job if the o/p contains more than 1 row returned.

               

              As i dont find much on this anywhere in the BMC documentation nor communities.

              • 4. Re: Run a job based on o/p of the Database Query Job
                Ilyas Shaikh

                Hi Avneesh,

                 

                I am sorry, I didn't understand your requirement, if you are looking to read 0 from output then you can define output statement like below:

                 

                And if you want to trigger next job if the output returns more than 1 record, you can try the following: