#!/usr/bin/ksh #set -x # ------------------------------------------------------------------------------------- # contains also : # Script: explain7.sql & explain8.sql # Author: Jonathan Lewis # Purpose: q and d to execute explain plan (Oracle 7.3) # # Adapted to Smenu by bpa : 16-08-2000 # # ------------------------------------------------------------------------------------- NN= NC= if echo "\c" | grep c >/dev/null 2>&1; then NN='-n' else NC='\c' fi SBINS=$SBIN/scripts WK_SBIN=$SBIN/tmp HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` # ------------------------------------------------------------------------------------- show_help() { cat < -f -m xpl -bu -f Notes bu : Connect as SYS and becore Oracle Schema to run explain plan table in f : Full path of the file containing the SQL to analyze h : This Help u : Oracle Schema to run explain plan table in m : Jonathan table plan display mode s : silence mode EOF } # ------------------------------------------------------------------------------------- if [ -z "$1" ];then show_help exit fi SILENT=N typeset -u PAR_USER while [ -n "$1" ] do case $1 in -h ) show_help exit ;; -f ) PAR_SQL=$2; shift ;; -u ) PAR_USER=$2;shift ;; -bu ) PAR_USER=$2;shift BECOME="alter session set current_schema=\"$PAR_USER\";";; -s ) SILENT=Y ;; -m ) JL_COMP_MODE=TRUE ;; * ) echo "Invalid option" esac shift done if [ -n "$PAR_USER" ];then S_USER=$PAR_USER else echo $NN " Oracle user to use --> $NC" read S_USER fi if [ -n "$PAR_SQL" ];then SQL=$PAR_SQL else echo $NN " File Sql --> $NC" read SQL fi VAR=`basename $SQL | sed 's/\.sql//'` TSQL=$SBIN/tmp/txsql_$VAR.sql FOUT=$SBIN/tmp/explain_$VAR.txt > $TSQL echo "$BECOME" >> $TSQL . $SBIN/scripts/passwd.env . ${GET_PASSWD} $S_USER $ORACLE_SID if [ "x-$CONNECT_STRING" = "x-" ];then echo "could no get a the password of $S_USER" exit 0 fi export S_USER VAR=`$SBINS/smenu_check_exists.sh plan_table` if [ ! $? -eq 0 ];then echo "Ouch ! There is a problem with plan_table in Schema $S_USER" echo " Connect an eventually run @?rdbms/admin/utlxplan" exit fi cat >>$TSQL <> $TSQL echo "/" >> $TSQL if [ "$JL_COMP_MODE" = "TRUE" ];then cat >>$TSQL <>$TSQL <