storing database query in a variable

I am executing a SQL query in Unix Server:
select status,location from user_information where request_id='DS-43720'

In shell script I am writing this query in the below manner:

echo "select status,location from user_information where request_id='DS-43720' ;" >> $directory/info.sql

//(here $directory is my home folder in Unix Server)

echo "EXIT" >> $directory/info.sql

sqlplus -s $sUserId/$sUserPassword@$ORACLE_SID @$directory/info.sql 1>>$directory/info.log 2>>$directory/info.log

Now how do I store those two column values returned in Sql query in a Unix Variable??

Show us what the output looks like and we can probably come up with something. In the meantime, I'd suggest that you want something like:

myvariable=`long-sql-command`

Use of awk and cut should be able to split out the data in the columns.

Without one of the redirects (at a guess, you should still redirect STDERR to the log but stop redirecting STDOUT so the calling script can capture it instead).

can you mention the awk and cut commands format?

You'd need to show us the output that needs splitting up first sorry :wink: