Hello,
I am trying to use the eval {...} function to do a non-select database
action, then checking the $@ to see if I get an error. If there is an error
then I write a message out to a log file. I have had this work in an earlier
version of DB!.
My current environment is: Solaris 2.8, Oracle 8.1.7, perl v5.6.0, DBD 1.06
and DBI 1.14
my first script is:
[get the userid password and SID for Oracle bits]
$dbh = DBI->connect($DSN, $uid, $pw)
|| die "Cannot connect to $DBI: $DBI::errstr\n" unless $dbh;
$strt_date = &ParseDate("today");
$start_date = &UnixDate($strt_date,"%d-%m-%Y %H:%M:%S");
printf LOG_FILE "Start Run: $start_date\n";
printf LOG_FILE "Creating Index gl_ap_po_dtl_idx\n";
eval {
$dbh->do(qq[drop index gl_ap_po_dtl_idx]);
};
if ($@) {
printf LOG_FILE "Error creating INDEX gl_ap_po_dtl_idx\n\t\t
$DBI::errstr\n";
}
printf LOG_FILE "Finished creating Indices\n";
This produces nothing in the log file nor anything on the console.
If I do the following:
eval {
$dbh->do(qq[drop index gl_ap_po_dtl_idx]) || printf LOG_FILE
"Error creating INDEX gl_ap_po_dtl_idx\n\t $DBI::errstr\n";
};
if ($@) {
printf LOG_FILE "Error creating INDEX gl_ap_po_dtl_idx\n\t\t
$DBI::errstr\n";
}
printf LOG_FILE "Finished creating Indices\n";
At least I get an message on the console running the job, but I still get
nothing in the log file.
What am I missing here? I should be able to get the error string into the
log file. I am getting messages, such as the start and stop times into the
file.
Any help would be appreciated.
Thanks
---
Ronald Warden
Ministry for Children and Families
356-0466
Data Analysis Branch