title: batch script to execute sqloader
body: <p>I need to use the sql-loader to import some data into a table.
  Here is my batch-script:</p>
  
  <pre><code>@echo off
  for %%i in ("C:\Users\test\*.csv") do (
  SET tmpFile=%%~ni
  echo load data                                                      &gt;controlfile.ctl
  echo INFILE 'controlfile.ctl'                                               &gt;&gt;controlfile.ctl
  echo into table TABLE_NAME                                          &gt;&gt;controlfile.ctl
  echo append                                                         &gt;&gt;controlfile.ctl
  echo fields terminated by ','                                       &gt;&gt;controlfile.ctl
  echo OPTIONALLY ENCLOSED BY '"' AND '"'                             &gt;&gt;controlfile.ctl
  echo trailing nullcols                                              &gt;&gt;controlfile.ctl
  echo            (                                                   &gt;&gt;controlfile.ctl
  echo                 COLUMN1 CHAR(4000),                                &gt;&gt;controlfile.ctl
  echo                 COLUMN2 CHAR(4000),                            &gt;&gt;controlfile.ctl
  echo                 COLUMN3 CHAR(4000),                                &gt;&gt;controlfile.ctl
  echo                 FILE_NAME  %tmpFile%                           &gt;&gt;controlfile.ctl
  echo            )                                                   &gt;&gt;controlfile.ctl
  sqlldr db_user/db_pw CONTROL='C:\test\controlfile.ctl' LOG='C:\Users\test\mylog.log' skip=1
  ) 
  pause
  </code></pre>
  
  <p>Normally you have a control-file and a script that executes this file, however
  you cannot pass parameter to the control-file. IN my case, I want to save the fileName on the column in the table. Therefore I need to create the control-file on the fly, because on this way I can pass the fileName as a parameter (tmpFile)</p>
  
  <p>However, I am stuck and cannot go further. </p>
  
  <p>First, the control-file will be generated however most of the content is missing:</p>
  
  <pre><code>  COLUMN1 CHAR(4000
                COLUMN2 CHAR(4000),                            
                COLUMN3 CHAR(4000),
            FILE_NAME test                         
             )  
  </code></pre>
  
  <p>And secondly, I get this message on my cmd:</p>
  
  <pre><code>The process cannot access the file because it is being used by another process.
  </code></pre>
  
  <p>Ignore for a moment the second part (or maybe you know exactly why I get this error)...Why is most of the content missing in my control-file? Can someone pls help me...I am stuck and don't know what to do</p>