#!/bin/csh 

#**************************************************************#
#                                                              #
#  Job j280sum.inx will recreate the indexes on table t280sum  #
#                                                              #
#**************************************************************#

set homedir  = '/home/j280sc/SCRIPTS'
cd $homedir
set sysdir   = '/home/j280sc/SYSTEM'
set fmtdir   = '/home/j280sc/TABLES'

echo ' '
echo '**=====================================================**'
echo '** j280sum.inx:  begin execution                       **'
echo '**=====================================================**'

set server   = 'SCPROD3' 
set dbname   = 'd280db1' 
set tbname   = 't280sum'
set user     = `cut -c1-8 $sysdir/logon_id`
set pswd     = `cut -c10-18 $sysdir/logon_id`
set statusdb = 'd280db1'  
set sybrel   = 'source/1002'

#**************************************************************#
# erase any existing output file                               #
#**************************************************************#

if ( -e ${tbname}.out ) then
  rm ${tbname}.out
endif

#**************************************************************#
# drop the indexes on t280sum                                  #
#**************************************************************#
 
date
$SYBASE/${sybrel}/bin/isql -U$user -P$pswd -S${server} -o ${tbname}.out <<EOF1
use ${statusdb}
go

print '*isql* ---------------------------------------------'
print '*isql* Create INDEXES on d280db1.dbo.t280sum        '
print '*isql* ---------------------------------------------'
print ' '
print '*isql* Create INDEX x280sum1 on d280db1.dbo.t280sum '
go
  create unique nonclustered index x280sum1 on                                     
         t280sum                                                                
         ( f_fypd                                                              
          ,f_loc_c                                                              
          ,f_div_c
          ,f_dpt_c
          ,f_invtyp_c
          ,f_syssrc_c
          ,f_stg_c
          ,f_fop_c
	  ,f_afm_c      
         ) with fillfactor = 90                                                 
go                                                                              
 
print '*isql* Create INDEX x280sum2 on d280db1.dbo.t280sum '
go
  create index x280sum2 on
         t280sum
         ( f_loc_c
         , f_fypd
         ) with fillfactor = 90
go                   
 
print '*isql* Create INDEX x280sum3 on d280db1.dbo.t280sum '
go
  create index x280sum3 on
         t280sum
         ( f_dpt_c
         , f_fypd
         ) with fillfactor = 90
go
 
print '*isql* Create INDEX x280sum4 on d280db1.dbo.t280sum '
go
  create index x280sum4 on
         t280sum
         ( f_invtyp_c
         , f_fypd
         ) with fillfactor = 90
go
 
print '*isql* Create INDEX x280sum5 on d280db1.dbo.t280sum '
go
  create index x280sum5 on
         t280sum
         ( f_afm_c   
         , f_fypd
         ) with fillfactor = 90
go

declare @rc int
declare @rows int
select @rc = @@error, @rows = @@rowcount
if (@rc != 0)
   begin
   print '*isql*****ERROR****'
   print '*isql*non-zero return from t280sum drop indexes = %1!', @rc
   return
   end
else print '*isql* INDEXES were Successfully CREATED for d280db1.dbo.t280sum'
go
EOF1
 
rxx $sysdir/ERROR_CK_SYB ${tbname}.out
set rc = $status

date
if ($rc != 0) then
  echo '*AIX* ERRORS Found '
  exit ($rc)
endif

echo ' '
echo '*AIX*Successful exit - '
echo ' '
echo '**=====================================================**'
echo '** j280sum.inx:  end execution                         **'
echo '**=====================================================**'

exit
