title: Using Batch Script connect to oracle db run a select command and output all data to a flat file
body: <p>I am trying to create a batch file for windows (XP) which will have several sqls and when its run it would
  1. connect with oracle
  2. set the userid/password/schema
  3. run each sql in the loop and 
  4. output each sql outputs to its own flat file.</p>
  
  <p>I have started the script </p>
  
  <pre><code>@ECHO off
  
  SET STATE=fl
  TABLE1=AGENCY
  set SQL1="SELECT Column_ID||CHR(31)||column_ENTITY_CD||CHR(31) FROM AGENCY"
  set TABLE2=FIRM
  set SQL2="SELECT  Column_ID||CHR(31)||Column_NM||CHR(31) FROM FIRM"
  set TABLE3=FL_CO_LOB
  Set SQL3="SELECT Column_ID||CHR(31)||Column_LOB_CODE||CHR(31) FROM FL_CO_LOB"
  ...
  SET NumberOfTables=19
  SETLOCAL ENABLEDELAYEDEXPANSION
  
  
   FOR /l %%A IN (1,1,%NumberOfTables%) DO (
  
      echo !SQL%%A!
  
  
    )
   endlocal
  </code></pre>
  
  <p>I can get the SQL out of the variable but don't have any clue how to connect to oracle and run the sql and get the output to a defined file.</p>
  
  <p>please give me some direction.</p>
  
  <p>one thing to notice that the echo is printing including the double quote. but If i don't have them then it just print the 1st word not the whole query.</p>
  
  <p>Thanks</p>