1

I have written a script so that i can read from an oracle database and display it once i run the script. Is there any way that I can transfer the result to a variable ( Eg:output ) so that I can use if for some other calculations?

$ORACLE_HOME/bin/sqlplus -s /nolog<<EOF
connect useid/password@CFQ143
set pages 0 feed off
select count (platform) from platformspecific where platform='EF';
exit
EOF

2 Answers 2

1

If your current command prints the output in the console window, you should be able to do:

VARIABLE="$($ORACLE_HOME/bin/sqlplus -s /nolog<<EOF
connect useid/password@CFQ143
set pages 0 feed off
select count (platform) from platformspecific where platform='EF';
exit
EOF)"

And print out your variable:

echo "${VARIABLE}"
Sign up to request clarification or add additional context in comments.

1 Comment

hey i got the answer by doing the same thing u did but removing the "
0

this will also work:

var=$($ORACLE_HOME/bin/sqlplus -s /nolog<<EOF
connect useid/password@CFQ143
set pages 0 feed off
select count (platform) from platformspecific where platform='EF';
exit;
EOF) 
echo $var

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.