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 > Hlp needed for new bie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-17-10, 08:20
banumyname banumyname is offline
Registered User
 
Join Date: Aug 2010
Posts: 8
Hlp needed for new bie

i am new to shell scripting..

I had a requirement that needs to find whether the database was backed up or not in last 24 hrs .i am tring to query it in my catalog database if i query

select owner from from dba_objects where object_name='rc_database';

it will give me all the databases that are reciding on thar catalog database

and i need to query

select BACKUP_TYPE,START_TIME,COMPLETION_TIME from metat.rc_backup_piece where start_time > (sysdate -1);

gives the back ups started since last day out put is like this for this query (metat is the one of the database name)

in this way the loop need to run for all the database names that we get from the rc_database view ,

the o/p for this statement looks like

B START_TIM COMPLETIO
- --------- ---------
L 16-AUG-10 16-AUG-10
D 16-AUG-10 16-AUG-10
L 16-AUG-10 16-AUG-10
D 16-AUG-10 16-AUG-10

so if no lines are selected for this start_time then need to get a mail for the group.


THANKS ALL PLEASE HELP ME OUT

Last edited by banumyname; 08-17-10 at 08:28.
Reply With Quote
  #2 (permalink)  
Old 08-19-10, 07:42
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Replace isqlcmd in the below code with whatever command you use to run sql commands.
Code:
#!/usr/bin/ksh
getdbnm()
{
isqlcmd <<EOF
select owner from from dba_objects where object_name='rc_database';
EOF
}
for n in $(getdbnm)
do
isqlcmd <<EOF
select BACKUP_TYPE,START_TIME,COMPLETION_TIME 
from $n.rc_backup_piece where start_time > (sysdate -1); 
EOF
done
Reply With Quote
  #3 (permalink)  
Old 08-19-10, 07:53
banumyname banumyname is offline
Registered User
 
Join Date: Aug 2010
Posts: 8
Quote:
Originally Posted by pdreyer View Post
Replace isqlcmd in the below code with whatever command you use to run sql commands.
Code:
#!/usr/bin/ksh
getdbnm()
{
isqlcmd <<EOF
select owner from from dba_objects where object_name='rc_database';
EOF
}
for n in $(getdbnm)
do
isqlcmd <<EOF
select BACKUP_TYPE,START_TIME,COMPLETION_TIME 
from $n.rc_backup_piece where start_time > (sysdate -1); 
EOF
done
Thanks i try that and let you know

Thank you so much
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