Hi All,
I have something like this where i want to concanate two fuction.
I have created two function SQL () and ORA_CONN() (where SQL Query is there in SQL Function which i want to execute, And ORA_CONN is for oracle connection).
SQL ()
{
echo "set linesize 150"
echo "set pagesize 100"
echo "spool table_analyzed_avg_row_lenght.alert"
echo "select owner||'.'||table_name "Table_Name" ,AVG_ROW_LEN,LAST_ANALYZED from dba_tables where upper(owner) not in ('SYS','SYSTEM','PUBLIC') ORDER BY OWNER;"
echo "spool off"
echo "exit"
}
ORA_CONN ()
{
DBUSER=$1
DBPASS=$2
DBSID=$3
sqlplus -s ${DBUSER}/${DBPASS}\@${DBSID}
#@$HOME/scripts/Table_Analyzed_Avg_Row_Length.sql > $LOCATION/log/$SID/$LogFileName
}
Now i want to run this as ,which will call to run my SQL Query in this ORA_CONN.
for that my logic is
for SID in `cat $ORATAB | awk -f\# {print}| cut -d":" -f1`
VAR=`grep -i $SID $LOCATION/.DBCONFIG.cfg | cut -d"|" -f1`
USERNAME=`grep -i $SID $LOCATION/.DBCONFIG.cfg | cut -d"|" -f2`
export USERNAME
echo $USERNAME
PASSWORD=`grep -i $SID $LOCATION/.DBCONFIG.cfg | cut -d"|" -f3`
export PASSWORD
echo $PASSWORD
SQL | `ORA_CONN $USERNAME $PASSWORD $SID`
this is to reteive the username / password from .DBCONFIG.cfg file
Problem is if i hard codded the username and password and simply use
SQL | ORA_CONN
then it works but i dont want to run as hard codded , i want it to retreive the username password from file.
How to resolve this
SQL | `ORA_CONN $USERNAME $PASSWORD $SID`
Thanks in Advance