Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 11: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, 13: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, 12:52
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 38
share the script with me please dude ! !
Reply With Quote
  #4 (permalink)  
Old 02-13-08, 12: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

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