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?
my cat1.txt
1111
2334
2234
3333
4444
....
....
etc.
my SQL Statement
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 = &1
spool &&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 >= 23 and day <= 30
and (prod_bill) in ('1111','2334','2234','3333','4444')
/
spool off
exit
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 :-)
from prod_trans
where m_date = 11 and day >= 23 and day <= 30
and (prod_bill) in ($2)
MY SHELL SCRIPT
#!/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