Assigning multiple column's value from Oracle query to multiple variables in UNIX

Hi All,

I need to read values of 10 columns from oracle query and assign the same to 10 unix variables. The query will return only one record(row).

I tried to append all these columns using a delimiter( ; ) in the select query and assign the same to a single variable(V) in unix. I thought I could use 'cut' and assign values to all the required 10 variables from V.

But the thing is some of the the columns have special character and it is kind of hard for me to cut out the required details. Sometimes the delimiter( ; )itself is present in column value. Also the code is very lengthy.

Is there a better way to assign multiple column values from query to unix variables.?

Also when i read '-e' from query and pass it unix varaible it becomes '?e'. Is there anyway we could solve this.

Thanks.

$ echo ${.sh.version}
Version M 93t+ 2009-05-01
$ s="a b c d e f g h i j"
$ set -- $s
$ echo $1
a
$ echo $3
c
$ echo $5
e

Why would you try using read -e to process output from a database query? The read -e option is only intended to process input from a terminal. Try:

IFS=';' read -r v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 <<EOF
$V
EOF

You need to make sure that the delimiter is NOT part of the data; I remember faintly ORACLE allows for that (set COLSEP ...). Then, you don't need a shell variable to hold the selection's interim result, try

IFS='X' read -r v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 <<EOF
$(sql ... )
EOF