title: Oracle SQL Loader using batch and command file in windows 7
body: <p>I am trying to automate the entire data loading from a flat file to a table in database in Windows 7 environment.</p>
  
  <p>So, I created a windows batch file(Data_Load.bat) in <code>C:/Data_Load</code> folder. This takes the input as to which data has to be loaded. Once it takes the input, it will invoke the windows command file(Data_Load.cmd) in <code>C:/Data_Load/CMD_File</code>.</p>
  
  <p>In the Data_Load.cmd, I gave the oracle <code>SQL*Loader</code> command. This loads the control file which is present in <code>C:/Data_Load/CTL_File</code>. </p>
  
  <p>The <code>SQL*Loader</code> command in Data_Load.cmd file is given below.</p>
  
  <pre><code>sqlldr %_userName%/%_password%@%_serNm% 
        control=.\Data_Load\CTL_File\%_jobNm%.CTL
        log=.\Data_Load\CTL_File\%_jobNm%_%_datetime%.log
        bad=.\Data_Load\CTL_File\%_jobNm%_%_datetime%.bad &gt; .\Data_Load\CTL_File\\%_jobNm%_%_datetime%.log 2&gt;&amp;1
  </code></pre>
  
  <p>Here <code>%_userName%</code>, <code>%_password%</code> and <code>%_serNm%</code> are the database parameters which I took the input in Data_Load.bat file.</p>
  
  <p>After SQL Loader, I am using the below fine to notify an error.</p>
  
  <p>set _rejrec=
  FOR /F "tokens=*" %%G IN ('findstr /x /c:"Total logical records rejected:         0" .\Data_Load\CTL_File\%<em>jobNm%</em>%_datetime%.log') do set _rejrec=%%G</p>
  
  <p>IF "%_rejrec%"=="" (ECHO ECHO. !!!!!!! Errors in Load. Please check logs. Exiting. !!!!!!!
       PAUSE
       GOTO:EOF
       )else (echo CTL Load completed successfully !)
  ECHO.</p>
  
  <p>When I try to execute it, it throws an error in the log file :</p>
  
  <pre><code> SQL*Loader-522: lfiopn failed for file (.\Data_Load\CTL_File\Account_Load_09_15_2014_0700AM.log)
  </code></pre>
  
  <p>I gave all the permissions("Full Control") to every folder and every file. It is weird to get this error. So, could you please let me know if there is anything I am missing in the program?</p>
  
  <p>Thanks In Advance !</p>