title: SQL PLUS query result save to variable in batch file for further processing
body: <p>I have been using the following command in my batch script to fetch the result from a remote database. </p>
  
  <pre><code>for /f  %%m in ('sqlplus -S debayan/[pwd]@[ip]:[port]/[DBInstance] @selectcommands.sql') do set theValue=%%m 
  echo on 
  echo "%theValue%"
  PAUSE
  echo off 
  </code></pre>
  
  <p>on printing , the value comes as 
  <code>echo ""</code> without the value of the variable <code>theValue</code> which should return the value of the select query.</p>
  
  <p>My sql file has the following simple statement </p>
  
  <pre><code>set termout off
  set echo off 
  set pagesize 0
  set linesize 500
  set heading off
  set verify off
  set feedback off
  set heading off
  set serveroutput on
  whenever sqlerror exit 16
  whenever oserror exit 8
  set autocommit on
  SET ROWCOUNT 1
  set heading off
  select count(*)  from books;
  commit;  
  exit;
  </code></pre>
  
  <p>Any help would be very much appreciated.</p>