Radoulov,
Your code is OK if I use only one variable. What the case for my below script?
== Uncoted $var1
printf "%s\n" "set pages 0 serverout on feed off" \
"select ENAME from emp;" \
"select sysdate from dual;" \
"select min(sal) from emp;" \
"select max(sal) from emp;" \
"select avg(sal) from emp;" \
| sqlplus -s scott/tiger \
| { read var1; read var2; read var3; read var4; read var5;
}
echo "Employee Name is" $var1
echo "Date is $var2"
echo "Minimum of Salary is $var3"
echo "Maximum of Salary is $var4"
echo "Average of Salary is $var5"
Result is as below:
Employee Name is SMITH
Date is ALLEN
Minimum of Salary is WARD
Maximum of Salary is JONES
Average of Salary is MARTIN
== For coted $var1
printf "%s\n" "set pages 0 serverout on feed off" \
"select ENAME from emp;" \
"select sysdate from dual;" \
"select min(sal) from emp;" \
"select max(sal) from emp;" \
"select avg(sal) from emp;" \
| sqlplus -s scott/tiger \
| { read var1; read var2; read var3; read var4; read var5;
}
echo "Employee Name is $var1"
echo "Date is $var2"
echo "Minimum of Salary is $var3"
echo "Maximum of Salary is $var4"
echo "Average of Salary is $var5"
Result is same as previous case (which is incorrect):
Employee Name is SMITH
Date is ALLEN
Minimum of Salary is WARD
Maximum of Salary is JONES
Average of Salary is MARTIN
Result which Iam expecting is:
Employee Name is SMITH ALLEN WARD JONES MARTIN BLAKE CLARK
Date is 30-JAN-07
Minimum of Salary is 12000
Maximum of Salary is 99999
Average of Salary is 24571.2857
Please help me again with your knowledge.
With Regards,
Ganapati