Db2

Db2

Connect with Db2, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
  • 1.  DMC 3.1.11 - Jobs - SQLScript - can I cause a failure if records are returned?

    Posted Wed June 14, 2023 02:40 PM

    I am trying to use DMC as a nice cetralized space to monitor for RUNSTATS and REBINDS on our customer databases (130+) that are supposed to be scheduled weekly.  I've written a nice query that pulls from SYSCAT.TABLEs and SYSCAT.PACKAGES for the info I'm looking for.  I would like the query to not return data if everything has been updated within the last 30 days.  If outside of the 30 day window, I would like to see the records that are returned.  Unfortunately, I currently see a SUCCESS completion regardless, I would like to see a WARNING if records are retuned so that I know what customers need reviewing and which ones don't.

    Any suggestions.  I have not gone to a CLP or Shell script as we do not have OpenSSH on the customer servers yet.

    Thank you



    ------------------------------
    Freddie Callander
    ------------------------------


  • 2.  RE: DMC 3.1.11 - Jobs - SQLScript - can I cause a failure if records are returned?

    Posted Wed June 14, 2023 05:03 PM
    Edited by Cintia Ogura Wed June 14, 2023 05:03 PM

    Hello Freddie,

    Unfortunately you can not force a return status using jobs.

    Here is a list of Job Status in DMC:

    https://www.ibm.com/docs/en/db2-data-mgr-console/3.1.x?topic=jobs-job-status

    My recommendation is to use Custom alerts instead.

    I hope that helps!



    ------------------------------
    Cintia Ogura
    ------------------------------



  • 3.  RE: DMC 3.1.11 - Jobs - SQLScript - can I cause a failure if records are returned?

    Posted Thu June 15, 2023 09:49 AM

    Hi Freddie,

    I am not familiar with DMC however, it appears that when you submit SQL statements directly DMC is using a JDBC connection to the database, so this may be worth a try,

    I believe you can submit multiple statements in a job, so you create two statements.

    The original statement to list the packages and tables

     SELECT PKGSCHEMA, PKGNAME 
      FROM SYSCAT.PACKAGE 
     WHERE LAST_BIND_TIME < CURRENT TIMESTAMP - 30 DAYS;

    Then a second statement

     SELECT 'X' 
       FROM SYSIBM.SYSDUMMY1                   
      WHERE (SELECT 'X'  AS MARKER1
               FROM SYSCAT.PACKAGE 
              WHERE LAST_BIND_TIME < CURRENT TIMESTAMP - 30 DAYS
             UNION ALL                                     
             SELECT 'X' AS MARKER1 FROM SYSIBM.SYSDUMMY1              
            ) = 'X'                                        
       ;                                                   

    The second statement should error out if one or more rows are returned from syscat.package and the job will end with an error(not a warning).  If no rows are returned it will be successful.



    ------------------------------
    Tommy Petersen
    ------------------------------



  • 4.  RE: DMC 3.1.11 - Jobs - SQLScript - can I cause a failure if records are returned?

    Posted Fri June 16, 2023 06:57 PM

    Tommy, 

    Thank you so much for the query.  This works exactly the way I need it to.  This will help a lot in automating our monitoring.  



    ------------------------------
    Freddie Callander
    ------------------------------



  • 5.  RE: DMC 3.1.11 - Jobs - SQLScript - can I cause a failure if records are returned?

    Posted Mon June 19, 2023 07:58 AM

    You are welcome.  Thank you for the feedback.



    ------------------------------
    Tommy Petersen
    ------------------------------