Hi All,

I am getting the following error below when running my CGI script. I have went through the code but can't seem to sift where exactly it is saying on each of the respective lines. For the error on line 65 is it because I have a localized variable and I use it twice, one being to call the query to run it? And for the error on line 62 am I calling the package wrong? And if that is the case how come the decrypt username isn't erroring out? Can someone please guide me on where to look? I'm just trying to develop a script that runs a sql statement with the trade ids given from the user...I'll have to create a form page for that.

ERROR
perl Red_Drill.cgi
"my" variable $red_select masks earlier declaration in same scope at Red_Drill.cgi line 65.
Undefined subroutine &main::decrypt_murex_password called at Red_Drill.cgi line 62.

#!/opt/perl/1588/bin/perl -w

require "cgi-lib.pl";

use CGI qw(:standard);
use strict;
use warnings;
use DBI;
use Config::Std; # Uses read_config to pull info from a config files. enhanced I
#NI format.
use vars qw ($Source_Host $Trade_ID $ACCT_PROD_STS $PROD_TYPE $CTPY_ID_TYPE $CTPY_SPN $NM_ALIAS $TRD_DATE $NXT_CSHFLW_DATE $EFFTVE_DATE $MATR_DATE $M_BUY_SELL $CURRCY $MTM_USD $RPLCE $OU $LE $OWN_SPN $ID_PRTFLO $NM_PRTFLO);

read_config "l2cgi.cfg" => my %cgi_config_hash;

#To process input of SPNS to place in Panama SELECT query and output on webpage
#my $spn = param('spn');
my $red_select = ("select
'Murex' AS Source_System,
DTTA.JPM_TRADE_ID,
DTT.ACCOUNTING_PRODUCT_STS,
DTT.ACCOUNTING_PRODUCT_STS,
DTT.PRODUCT_TYPE,
'SPN' as COUNTERPARTY_ID_TYPE,
DTTA.COUNTERPARTY_SPN,
A.NM_PARTY_ALIAS,
TO_CHAR(TRUNC(DTT.M_TRADE_DAT, 'DDD'), 'DD-MON-YYYY') as TRADE_DATE,
TO_CHAR(TRUNC(A.NEXT_CASHFLOW_DATE, 'DDD'), 'DD-MON-YYYY') as NEXT_CASHFLOW_DATE,
TO_CHAR(TRUNC(DTT.EFFECTIVE_DATE, 'DDD'), 'DD-MON-YYYY') as EFFECTIVE_DATE,
TO_CHAR(TRUNC(DTT.M_MATURITY, 'DDD'), 'DD-MON-YYYY')as MATURITY_DATE,
DTT.M_BUY_SELL,
DTTA.CURRENCY,
DTTA.SUM_MTM,
DTTA.SUM_MTM_USD,
REPLACE(DTTA.REGION_DATASET,'ENTITIES','EOD'),
RTCR.ID_OU,
RTCR.ID_LE,
DTTA.OWNER_SPN,
RTCR.ID_PORTFOLIO,
RTCR.NM_PORTFOLIO
from
PANAMA.DPS_TBL_TRADE_ATTRIB DTTA,
PANAMA.DPS_TBL_TRADE DTT,
(
SELECT DTTA.JPM_TRADE_ID,
MAX(DTC.CASHFLOW_DATE) AS NEXT_CASHFLOW_DATE,
RTCP.NM_PARTY_ALIAS
FROM
PANAMA.DPS_TBL_TRADE_ATTRIB DTTA,
PANAMA_REF_DATA.REF_TBL_CRDT_PARTY RTCP,
PANAMA.DPS_TBL_CASHFLOW DTC
WHERE DTTA.COUNTERPARTY_SPN IN (?,?,?,?,?)
AND DTTA.JPM_TRADE_ID = DTC.JPM_TRADE_ID 
AND DTTA.COUNTERPARTY_SPN = RTCP.ID_PARTY
GROUP BY DTTA.JPM_TRADE_ID, RTCP.NM_PARTY_ALIAS
) 
A,PANAMA_REF_DATA.REF_TBL_CRDT_PORTFOLIO RTCR
where DTT.JPM_TRADE_ID = DTTA.JPM_TRADE_ID
and (DTTA.INDEX_FLAG is NULL or DTTA.INDEX_FLAG = 'I')
and DTTA.JPM_TRADE_ID = A.JPM_TRADE_ID
and DTTA.BOOK = RTCR.NM_PORTFOLIO
order by 2");
my $l2_db_username = decrypt_murex_password($cgi_config_hash{'tacmon_write'}{'username'});#this sets the variable to decrypt the password within the l2cgi.cfg file, using the tacmon_write connection   
my $l2_db_password = decrypt_murex_password($cgi_config_hash{'tacmon_write'}{'password'});#this sets the variable to decrypt the password within the l2cgi.cfig file, using the tacmon_write connection
my $dbh=DBI->connect($cgi_config_hash{'tacmon_db'}{'dbi_connect'},$l2_db_username, $l2_db_password)|| die "ERROR opening database: $DBI::errstr\n";
my $sth = $dbh->prepare(my $red_select);
$sth ->execute;#make this a global variable, might have to revert back to local variable, will double check 
#my $final_spn = $spn  m/$d[0-9]\/\/;
my $output = (our @redspn); #send output to the array @redspn so it can then spliced into each row
print "Content-type: text/html\n\n";
print <<StartTable ;  # remember: no space after << !
  <table align="center" border="1" cellspacing="0">
    <tr>   <!-- start tag for first table row -->
     <th colspan="7">$Source_Host $Trade_ID $ACCT_PROD_STS $PROD_TYPE $CTPY_ID_TYPE $CTPY_SPN $NM_ALIAS $TRD_DATE $NXT_CSHFLW_DATE $EFFTVE_DATE $MATR_DATE $M_BUY_SELL
$CURRCY $MTM_USD $RPLCE $OU $LE $OWN_SPN $ID_PRTFLO $NM_PRTFLO</th>
    </tr>  <!-- end tag for first table row -->
StartTable
print "</table>\n" ;  # end tag for entire table


# start table and output first row of table

Recommended Answers

All 4 Replies

I resolved the first error for the "my" variable $dbh masks earlier declaration in same scope at Red_Drill.cgi line 69. But I can't seem to figure out the undefined subroutine error..any guidance possibly?

You're declaring the $red_select variable twice with "my".

Yes I fixed that one earlier(posted below my original comment)but can't seem to get the undefined subroutine error..any idea?

found the answer I was missing one of our packages! thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.