Hi,
I am very new to shell scripting and trying to write a simple shell script in which i am trying to achieve the following:
- Connect to oracle database hosted on a different server
- fire a query on the oracle db
- store the output in a variable
- use this variable for further logic
The code that i have written so far is as follows:
#!/bin/bash
#Connect to the database using sqlplus
sqlplus 'DBUSER/dbuser@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.199.106)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=PHYGD1)))' >> outputlogfile.log
# Fire the query on database
DCOFCVALUE=select sync_cmpl
from table(dbdev.db_inv_dtl_hdr)
where dc_id ='30'
and to_char(sync_req_dttm,'YYYYMMDD')= '20100331';
ENDSQL
# Check if DCOFCVALUE was succesful or not
if [ $DCOFCVALUE = Y ]
then
echo "DCOFCVALUE Succesfull\n"
exit 2
else
if [ $DCOFCVALUE = N]
then
echo "DCOFCVALUE Unsuccesfull\n"
exit 3
fi
fi
exit 0
Now the error message i am getting is as follows:
line 29: sync_cmpl: command not found
.line 30: syntax error near unexpected token `('
line 30: `from table(dbdev.db_inv_dtl_hdr)'
Could someone please guide where am I going wrong? And what is the correct way to write such a code.
Your help is highly appreciated!
Regards,
Shruti