Leandro Toshio Takeda
Leandro Toshio Takeda

Reputation: 1639

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

Upvotes: 4

Views: 5408

Answers (1)

shellter
shellter

Reputation: 37318

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

Upvotes: 6

Related Questions