Either add "{RaiseErrors => 1}" to the connect() or "$dbh -> {RaiseErrors} =
1;" somewhere before your eval{}.
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Warden, Ronald MCF:EX" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 11, 2001 12:56 PM
Subject: Question about errors out of an eval do combination


> 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.


Reply via email to