#$SQLPLUS -s 
$ORACLE_SCHEMA/$DB_PASSWORD@$ORACLE_SID <<EOF | tee -a $LOG_FILE 

 $SQLPLUS -s 
$ORACLE_SCHEMA/$DB_PASSWORD@$ORACLE_SID <<EOF >> $LOG_FILE 

 spool $LOG_FILE APPEND 

 set echo on 

 whenever sqlerror exit sql.sqlcode 

 declare 

   STR VARCHAR2(400); 

 begin 

   FOR TMP_IDX IN (SELECT TABLESPACE_NAME, OWNER, TABLE_NAME, INDEX_NAME 

                     from ALL_INDEXES 

                    WHERE OWNER = 'GCD' 

                    ORDER BY TABLESPACE_NAME, TABLE_NAME 

                    ) 

               LOOP 

     STR := 'ALTER INDEX ' || TMP_IDX.OWNER || '.' || TMP_IDX.INDEX_NAME || ' Rebuild'; 

     EXECUTE IMMEDIATE STR; 

   END LOOP; 

 end; 

 spool off; 

 exit; 

 EOF