title: How to covert PL/SQL .sql file to SQL*PLUS so it can be run with Windows Task Scheduler
body: <p>I'm trying to add the CONDITION_TEST.sql file to Windows Task Scheduler, so it will run automatically everyday.</p>
  
  <p>I created a .bat file that has the following text:
  <strong>sqlplus userid/password@csdpro @C:\Users\userid\Desktop\HCR_Datamart_Recon\CONDITION_TEST.sql
  echo commit; | userid/password$@csdpro</strong></p>
  
  <p>The CONDITION_TEST.sql file is created using PL/SQL. The line that now starts with the @, used to be a "select from" statement. I saved that block as a separate .sql file.</p>
  
  <pre><code>DECLARE
  v_chkt_dm date;v_chks_dm number;v_chkt_un date; v_dm_fix varchar2(20000);
  -----------------------------------------------------------------------------------  
  BEGIN
    Select /*+parallel (a,4)*/ trunc(max(a.action_timestamp))
     into v_chkt_dm
     from hcr_dm.hcr_dm_fact a;
    Select /*+parallel (a,4)*/ count(distinct a.src_table) 
     into v_chks_dm
     from hcr_dm.hcr_dm_fact a;
    Select /*+parallel (b,4)*/ trunc(max(b.action_timestamp))
     into v_chkt_un
     from hcr_sandbox.hcrdm_the_big_union b;
  -----------------------------------------------------------------------------------
   If v_chkt_un &lt; trunc(sysdate) then
    If v_chkt_dm = trunc(sysdate) and v_chks_dm = 9 then
       execute immediate 'truncate table HCR_SANDBOX.HCR_DM_FIX';
       commit;
    Else
       execute immediate 'truncate table HCR_SANDBOX.HCR_DM_FIXED_SUM';
       commit;
    END IF;
   Else  
    @V:\AccountingOperations\Statutory\ReneeGuo\AUTO_BIG_UNION\DM_FIX.sql;
   commit;
   END IF;  
  END;
  </code></pre>
  
  <p>After I run the scheduler, I got a screen like this (I typed the screen results below). The task stopped running after seeing the number 167, which I don't know what it means. Then if I hit ENTER, it will create a new integer on the next row.</p>
  
  <p>I haven't been dealing with SQL*plus a lot, so not sure what's gone wrong. Can any one help me with this? Thanks!</p>
  
  <pre><code>c:\Windows\system32&gt;sqlplus userid..... CONDITION_TEST.sql
  
  SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 24 09:10:35 2014
  
  Copyright &lt;c&gt; 1982, 2010, Oracle. All rights reserved.
  
  Connected to:
  Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Prodution With the Partitioning,     
  OLAP, Data Mining and Real Application Testing options
  
  167
  168
  169 _
  </code></pre>