Hi,
I need to export some entries from a table, from a specific column and then redirect them into a file.
I used sql plus, in order to fetch the entries and i put them in one variable.
When i am running the script it stuck at a point and does not move further.
I did something like:
$OUTPUT=`sqlplus -s $USER/$PASS@$INST << END
SELECT col1
FROM table
WHERE col2='A';
EXIT;
END`
for element in $OUTPUT
do
echo $OUTPUT
done
variables $USER/$PASS@$INST, contain correctly the db details, as per what i see after doing echo
Just my thoughts. you need to remove "$" sign from the variable name"OUTPUT". and for best practice you need to enclose your variables with curly brackets "{}" .
OUTPUT=$(sqlplus -s ${USER}/${PASS}@${INST} << END
SELECT col1
FROM table
WHERE col2='A';
EXIT;
END)
for element in $OUTPUT
do
echo $OUTPUT
done