#!/bin/sh

# date          author  purpose
# 12/20/96      T.Boss  creation from dbcc.sh code
# 04/21/97	T.Boss	moved $sapw inside EOTSQL script for security

perform_peter_dbcc ()
{

DATE=`date +%y%m%d`
server="peter"

for database in master
do

sapw=`cat ../.p11sapw`
ISSA="/export/sybase11/bin/isql -Usa -Speter -I/export/sybase11/interfaces -o$server.$database.dbcc.$DATE" 

$ISSA << EOTSQL
$sapw
dbcc checkdb($database)
go
dbcc checkcatalog($database)
go
dbcc checkalloc($database)
go

EOTSQL

done
}

#################################
perform_prod11_dbcc ()
{

DATE=`date +%y%m%d`
server="prod11"

#for database in CDB hss issc
#for database in issc
#for database in prrc prrc2 prrc_old
for database in issc
do

sapw=`cat ../.p11sapw`
ISSA="/export/sybase/bin/isql -Usa -Sprod11 -I/export/sybase11/interfaces -o $server.$database.dbcc.$DATE" 

$ISSA << EOTSQL
$sapw
use issc
go
dbcc checkdb($database)
go
--dbcc checkcatalog($database)
--go
--dbcc checkalloc($database)
--go

EOTSQL

done
}

#################################
perform_prod_dbcc ()
{

# prod.edison
DATE=`date +%y%m%d`
server="prod"
database="edison"

sapw=`cat ../.p10sapw`
ISSA="/export/sybase/bin/isql -Usa -Sprod -I/export/sybase/interfaces -o $server.$database.dbcc.$DATE" 

$ISSA << EOTSQL
$sapw
use master
go
sp_dboption edison, "single user", true
go
use edison
go
checkpoint
go
use master
go
dbcc checkalloc($database, fix)
go
sp_dboption edison, "single user", false
go
use edison
go
checkpoint
go
EOTSQL

}

############

perform_crimson_dev_dbcc ()
{

DATE=`date +%y%m%d`
server="crimson_dev"
database="master"

sapw=`cat ../.ibmsapw`
ISSA="/export/sybase/bin/isql -Usa -Scrimson_dev -I/export/sybase/interfaces -o $server.$database.dbcc.$DATE" 

$ISSA << EOTSQL
$sapw
dbcc checkdb($database)
go
dbcc checkalloc($database)
go
dbcc checkcatalog($database)
go
EOTSQL

}

####

#perform_prod_dbcc
#perform_prod10_dbcc
#perform_prod11_dbcc
perform_peter_dbcc

#perform_crimson_dev_dbcc