If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > looking for help with a DB2/Unix script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-08, 10:49
alzzzzzzzz alzzzzzzzz is offline
Registered User
 
Join Date: Jan 2008
Posts: 3
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.
Thanks!
Reply With Quote
  #2 (permalink)  
Old 01-03-08, 12:04
alzzzzzzzz alzzzzzzzz is offline
Registered User
 
Join Date: Jan 2008
Posts: 3
got it

actually was able to figure this out myself, thanks anyway.
Reply With Quote
  #3 (permalink)  
Old 02-10-08, 11:52
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
share the script with me please dude ! !
Reply With Quote
  #4 (permalink)  
Old 02-13-08, 11:29
alzzzzzzzz alzzzzzzzz is offline
Registered User
 
Join Date: Jan 2008
Posts: 3
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]

fi
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.

Al
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On