#!/usr/bin/perl use DBI; use strict; my $tdate = $ARGV[0]; my $dbh=DBI->connect("dbi:Oracle:dbname",username,password,{RaiseError => 1 , PrintError => 0}); my $x; open ($x, '>P_RUN_TIME_LOG.txt'); my $sqlstmt = "select to_date('$tdate','mm/dd/yyyy') from dual"; my $sth = $dbh->prepare($sqlstmt); $sth->execute() or die $dbh->errstr; my $tmp; $sth->bind_columns(undef, \$tmp); while($sth->fetch()) {$tdate = $tmp;} # LOOP THROUGH RESULTS $t = localtime(); print $x "DATE formatted at $t. Formatted DATE is $tdate.\n\n"; $t = localtime(); print $x "Executing FT_PROC at $t.\n\n"; $sqlstmt = "BEGIN FT_PROC($tdate); EXCEPTION WHEN others THEN sql_stmt := 'INSERT INTO P_LOG (PRCDR, FT_DATE, RUN_STATUS) VALUES ('FT_PROC', $tdate, 1)'; execute immediate sql_stmt; END;"; $sth = $dbh->do($sqlstmt) or die $dbh->errstr; $dbh -> disconnect;