#!/usr/bin/ksh # set -xv # author : B. Polarski # program : smenu_run_dbms_repair.ksh # date : 9 Decembre 2005 HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` LEN=70 # ------------------------------------------------------------------------------------- function help { cat < -tbs dbrep -c -rt -o -s dbrep -f -rt -o -s -p note : DEFAULT for REPAIR TABLE is REPAR_TABLE -r : create admin table -c : check object -f : fix object EOF exit } # ------------------------------------------------------------------------------------- function do_execute { LLEN=`expr 55 + $LEN` $SETXV sqlplus -s "$CONNECT_STRING" < \c" read TBS SQL="execute dbms_repair.admin_tables(table_name=> '$frepair_table', table_type=>dbms_repair.REPAIR_TABLE, action=>dbms_repair.CREATE_ACTION, tablespace=>'$ftable_space');" # ................................................. # # ................................................. elif [ "$CHOICE" = "FIX_OBJECT" ];then if [ -n "$fpartition" ];then P="partition_name => '$fpartition', " fi SQL=" set serveroutput on size 9999; declare v_cpt integer ; begin DBMS_REPAIR.FIX_CORRUPT_BLOCKS( schema_name => '$fschema', object_name => '$fobj', $P fix_count => v_cpt ); dbms_output.put_line('fix_count => '|| to_char(v_cpt)); END; / " # ................................................. # # ................................................. elif [ "$CHOICE" = "CHECK_OBJ" ];then unset VAR echo "start block ==> \c" read VAR if [ -n "$VAR" ];then BLOCK_START="block_start => $VAR," fi unset VAR echo "end block ==> \c" read VAR if [ -n "$VAR" ];then BLOCK_START="block_end => $VAR," fi SQL=" set serveroutput on size 9999; declare v_cpt integer ; begin DBMS_REPAIR.CHECK_OBJECT( schema_name => '$fschema', object_name => '$fobj', $BLOCK_START $BLOCK_END corrupt_count => v_cpt ); dbms_output.put_line('corrupt_count => '|| to_char(v_cpt)); END; / " fi if [ "$EXECUTE" = "YES" ];then do_execute else echo "$SQL" fi