title: Passing variable from shell script to sql statement
body: <p><br>I was trying to make cat1.txt as a variable ($2) so that it will be inserted in sql select statement. Is there a way to do this? <br></p>
  
  <pre><code>my cat1.txt
  1111
  2334
  2234
  3333
  4444
  ....
  ....
  etc.
  </code></pre>
  
  <p><br> my SQL Statement<br></p>
  
  <pre><code>set echo off linesize 280 pagesize 0 newpage 0 feedback 1 verify off head off    trimspool on
  alter session set sort_area_size=104857600;
  
  define filename = &amp;1
  
  spool &amp;&amp;filename
  prompt DATE TIME Service Name Amount
  
  select trim(to_char(trans_time,'yyyymmdd')) || chr(9) ||
     trim(to_char(trans_time,'hh24miss')) || chr(9) ||
     trim(prod_name)|| chr(9) ||
     (prod_price)
  where m_date = 11 and day &gt;= 23 and day &lt;= 30
  and (prod_bill) in ('1111','2334','2234','3333','4444')
  /
  spool off
  exit
  </code></pre>
  
  <p><br> I want to try this,please see below. Instead of manually typing the prod_bill make it as variable like the filename. Anything I should add to my shell script? Thanks :-)<br></p>
  
  <pre><code>from prod_trans
  where m_date = 11 and day &gt;= 23 and day &lt;= 30
  and (prod_bill) in ($2)
  </code></pre>
  
  <p><br>MY SHELL SCRIPT<br></p>
  
  <pre><code>#!/bin/sh
  
  export ORACLE_BASE=/u01/app/oracle
  export ORACLE_SID=prod
  export ORACLE_HOME=/u01/app/oracle/product/9.2.0
  export ORACLE_BASE ORACLE_HOME ORACLE_SID
  export PATH=$PATH:/usr/local/bin:$ORACLE_HOME/bin:/usr/sbin:/opt/java1.5/bin
  export USERNAME=prods
  export PASSWORD=prods
  export OUT_PATH=/home/prod/reports/adhoc/REp
  export SCRIPT=$OUT_PATH/BICScripts/Translog
  export OUTPUT=/home/prod/reports/adhoc/REp/Scripts/log/OUTPUT
  export FILENM=$OUTPUT/log_`date +%y%m%d`.txt
  sqlplus -s $USERNAME/$PASSWORD@$ORACLE_SID @$SCRIPT/log.sql $FILENM
  </code></pre>