i am using bash shell
Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127.
IFS=","
declare -a Arr=($Variable1);
SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE}
echo "set head off ; " > ${SQLCMD}
echo "set PAGESIZE 0 ;" >> ${SQLCMD}
echo "select columnname from tablename where colume = '${ABC}';" >> ${SQLCMD}
variable3=`${SQLPLUS} @${SQLCMD}`
try the below
SQLPLUS="sqlplus -s ${DBUSER}/${DBPASS}@${DBASE}"
you can even try the below for sqlplus
sqlplus -s ${DBUSER}/${DBPASS}@${DBASE} <<! | read variable3
set head off;
set pagesize 0;
select columnname from tablename where colume = '${ABC}';
exit;
!
export these variable:
SQLPLUS_PATH= path of sqlplus client export LD_LIBRARY_PATH=$SQLPLUS_PATH
export PATH=$PATHSQLPLUS_PATH
cd $SQLPLUS_PATH
sqlplus <DBUSERNAME>/<DBPASSWORD>//<IP>:<PORT>/<SID>
Hi Srini,
i tried using your method. Wheneever i am using IFS=",", sqlplus is throwing me error. If i comment out IFS=",", then sqlplus runs without any problem. Has this something to do with the shell?
What is the way to use array in shell?
Variable=MKT1,MKT2
Basically i want to capture MKT1 and MKT2 in array seperately. Comma is the delemiter. In bash,
IFS=","
declare -a Arr=($Variable);
where do you want to use the array values inside sqlplus?
No, i donot want to use the array variable inside sqlplus
Tyr the below
variable3=$(sqlplus -s ${DBUSER}/${DBPASS}@${DBASE} <<!
set head off;
set pagesize 0;
select columnname from tablename where colume = '${ABC}';
exit;
!)
If you dont want to use IFS in sql, you can change IFS after you are done with IFS. Let's say you want to use IFS below sql, you can do this way
old_IFS="${IFS}"
IFS=","
... code that uses ',' as IFS
IFS="${old_IFS}"
... sqlplus code
IFS=","
... rest of the code
IFS="${old_IFS}"