If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How to Join the two function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-04-09, 02:50
jhonddba jhonddba is offline
Registered User
 
Join Date: Jul 2009
Posts: 7
Arrow How to Join the two function

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
Reply With Quote
  #2 (permalink)  
Old 08-04-09, 07:49
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,448
Quote:
Originally Posted by jhonddba
How to resolve this
SQL | `ORA_CONN $USERNAME $PASSWORD $SID`
Can you please explain the purpose of the backquotes in the fragment above?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On