...
WHERE asof_date = '$test_date'
...
####
...
s/\$test_date/$test_date/g;
...
##
##
#===============================================#
$ss_source_file = "C:/code/mla/tmp.sql";
$test_date = "30-APR-2011";
$schema = "DEV";
#####################
%trancd_sql = (); # each SQL in a hash with a
# transaction number and associated SQL
open(SS_SOURCE, "< $ss_source_file ") || die "Can't open SQL source file! $!\n";
while () {
if (/^;/) { # the end of each SQL
$end_sql = 1;
$begin_sql = 0;
$trancd_sql{$tran_code} = $sql; ## push each tran_code/SQL into hash
$sql = '';
$tran_code = '';
}
## beginning of an sql
if (/^\s*-{2,}\s*tran_code\s*\d{4,}/) {
($tran_code) = $_ =~ /^\s*-{2,}\s*tran_code\s*(\d{4})/;
$begin_sql = 1;
$end_sql = 0;
}
if (($begin_sql == 1) && ($end_sql != 1)) {
#s/\$test_date/$test_date/g; # works if uncommented
#s/\$schema/$schema/g; # works if uncommented
$sql .= $_;
}
}
close(SS_SOURCE);
$trcd = 1;
while ($trcd > 0) {
print "Enter Tran code, or '0' to exit: ";
$trcd = ;
chomp($trcd);
print $trancd_sql{$trcd};
}
#====================================================#
##
##
#=====================================================#
-- tran_code 1752
SELECT *
FROM $schema.TRANSACTOPMS
WHERE TRANSACTION_CD IN ('146','147')
AND AMT < 0
AND ASOF_DATE = '$test_date'
;
-- tran_code 1753
SELECT *
FROM $schema.TRAN
WHERE TRANSACTION_CD IN ('196','197')
AND ASOF_DATE = '$test_date'
AND RECORD_VERSION_NBR = '0'
;
-- tran_code 1758
SELECT COUNT(SS_NO), SUM(ABS(SS_PRINCIPAL))
FROM $schema.SS_MLA_TRAN
WHERE INVESTOR_ID = '195'
AND MAN_CD = '4'
AND ASOF_DATE = '$test_date'
AND RECORD_VERSION_NBR = '0'
and GROUP_ID = 'PCC'
;
-- tran_code 1765
... and so on, you get the idea
;
#==================================================#
##
##
SELECT *
FROM DEV.TRANSACTOPMS
WHERE TRANSACTION_CD IN ('146','147')
AND AMT < 0
AND ASOF_DATE = '30-APR-2011'
##
##
SELECT *
FROM $schema.TRANSACTOPMS
WHERE TRANSACTION_CD IN ('146','147')
AND AMT < 0
AND ASOF_DATE = '$test_date'