Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Help with my perl, how to send email when sees error

Re: Help with my perl, how to send email when sees error

From: Ron Reidy <ron_at_indra.com>
Date: Tue, 25 Sep 2001 16:57:12 -0600
Message-ID: <3BB10BC8.F9511C99@indra.com>


Mike F wrote:
>
> Hi, Folks
> I have a perl scripts like this:
> ------------------------------------------------------
> sub trap_die
> {
> my @param = @_;
> $message = $param[0];
> $CommandString = "/bin/mailx -s \"$message\" xxxx\@yyyy.com ";
> system ( $CommandString );
> }
> use strict;
> use DBI;
>
> my $dbh = DBI->connect ( 'dbi:Oracle:test',
> 'system',
> 'manager',
> {
> PrintError => 0,
> RaiseError => 1,
> AutoCommit => 1
> }
> ) || die "Database Connection not made
> $DBI::errstr" ;
> my $sql = qq{ select * from global_name}
> my $sth = $dbh ->prepare($sql);
> $sth->execute();
> while (my @rows = $sth->fetchrow_array) {
> print "@rows[0]\n";
> }
> $sth->finish();
> $dbh->disconnect();
> -------------------------------------------------------
> For any reason there is an error, perl will exit. Everyday I have to
> read output files to see whether there is an error, how can I make a
> perl call my sub function TRAP_DIE so that when error, I will get an
> email?
> I tried to put the line
>
> if ($dbh->error) {trap_die("error");}
> but it will not work because the perl will exit as soon as it raise
> error.
>
> Thanks for your help.
>
>
>
> --
> Sent by dbadba62 from hotmail in area com
> This is a spam protected message. Please answer with reference header.
> Posted via http://www.usenet-replayer.com/cgi/content/new
You are not trapping errors correctly. See the DBI docs for use of RaiseError and how it works.

-- 
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
Received on Tue Sep 25 2001 - 17:57:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US