Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force SQLPLUS to output each row on new line

What is wrong here please?

RETVAL=`sqlplus -s user/pass@DB <<EOF
SET TRIMSPOOL ON PAGESIZE 0 COLSEP , FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF              
SELECT process_id, source, destination, type FROM table WHERE process_id IN ('123','456');
EXIT;
EOF`
if [ -z "$RETVAL" ]; then
  echo "No rows returned from database"
  exit 0
else
  echo $RETVAL
fi

The output is:

123,a c,2 456,a c,5

and should be:

123, a, c, 2
456, a, c, 5
like image 299
Leandro Toshio Takeda Avatar asked Oct 13 '25 08:10

Leandro Toshio Takeda


1 Answers

Did you try

 echo "$RETVAL" 

the nature of unquoted variables interpreted on the command-line or in a shell scripts is to strip out "exteraneous" formatting. ;-)

IHTH

like image 168
shellter Avatar answered Oct 15 '25 08:10

shellter