#!/usr/bin/ksh function help { cat < : Count occurence of same type of SQL (not using bind variable Len is the length of SQL string to scan. Default is 40 sqn -l : to change sql text length to display sqn -n : restrict to one username sqn -t : sort by text sqn -r : to limit rows sqn -e : sort by executions sqn -p : sort by parse calls sqn -u : sort by user opening sqn -c : sort by cpu sqn -o : sort by optimizer sqn -hv : show hash_value EOF } SILENCE=N OWNER= ROWNUM=30 LEN=60 COUNT_LEN=40 typeset -u UPPVAR unset HASH_VALUE while true do if [ -z "$1" ];then break fi case $1 in -hv ) HASH_VALUE=" HASH_VALUE, " ;; -e ) ORDER=" ORDER by executions desc" ;; -c ) ORDER=" ORDER by cpu_time desc" ;; -o ) ORDER=" and optimizer_cost is not null ORDER by optimizer_cost desc" ;; -cpt ) COUNT=TRUE ;; -l ) LEN=$2; COUNT_LEN=$2 shift ;; -p ) ORDER=" ORDER by parse_calls desc" ;; -u ) ORDER=" ORDER by users_opening desc" ;; -t ) ORDER=" ORDER by text " ;; -r ) ROWNUM=$2 shift ;; -n ) UPPVAR=$2 F_USER=" and u.username = '$UPPVAR' " shift ;; -cpt ) COUNT=TRUE ;; -h ) help exit ;; esac shift done if [ -n "$HASH_VALUE" ];then LEN=`expr $LEN - 9` fi HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` SBINS=$SBIN/scripts . $SBIN/scripts/passwd.env . ${GET_PASSWD} if [ "x-$CONNECT_STRING" = "x-" ];then echo "could no get a the password of $S_USER" exit 0 fi RET=`sqlplus -s "$CONNECT_STRING" < 30 ORDER BY 2 desc) where rownum < $ROWNUM / EOF fi