Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2008

    Unanswered: looking for help with a DB2/Unix script

    We are running AIX and DB2v9

    I need to do the following:

    Run a select statement (against a PS table)
    If a result is returned quit
    If no result is returned sleep for 15 minutes
    Repeat this 3 times
    If no result is returned the last time, send emails

    I have code to connect to DB2 and run SQL and send emails, but don't know how to check for result from SQL, OR Sleep/loop

    Any help would be appreciated.

  2. #2
    Join Date
    Jan 2008

    got it

    actually was able to figure this out myself, thanks anyway.

  3. #3
    Join Date
    Nov 2007
    share the script with me please dude ! !

  4. #4
    Join Date
    Jan 2008
    This is pretty simplistic, hope you weren't expecting something great...

    Base of script is:
    db2 -vt connect to databasename;

    db2 "select 1 from tablename \
    where whatever you are looking for ";

    if [ $? = "0" ]
    then echo "Entry found-batch ran"
    exit 0

    else echo "Entry not found-will sleep and check again"
    sleep 600
    [I]-------> repeat of query removed[/I]

    db2 quit;

    that's the base of it. works well....the removed part is that is sleeps for 10 minutes and checks again. After three tries it emails our operators a message. If you want the whole thing let me know.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts