perlCrazy has asked for the wisdom of the Perl Monks concerning the following question:
I am storing the error in ERROR_STR via hash. I have doubt:sub new { my $class = shift; my $self = bless {}, $class; my $dbh = shift || return (undef); $self->{dbh} = $dbh; # store the dbh for future use return $self; } sub getDDL { my $self = shift; my ($dbase,$tableName,$tableDtls) = @_; return (undef) if (!$dbase or !$tableName); my $tabDtlSql = qq/ ##some sql query /; my $tabDtlSth = $self->{dbh}->prepare($tabDtlSql); $tabDtlSth->execute or $self->{ERROR_STR} = "Can't execute SQL sta +tement: $DBI::errstr\n"; if ($self->{ERROR_STR}) { return (undef); } else { ## do some stuff... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Having problem with handling DBI error in object
by ikegami (Patriarch) on Jul 19, 2007 at 21:18 UTC | |
by perlCrazy (Monk) on Jul 19, 2007 at 21:35 UTC | |
by ikegami (Patriarch) on Jul 19, 2007 at 21:43 UTC | |
|
Re: Having problem with handling DBI error in object
by jZed (Prior) on Jul 19, 2007 at 21:25 UTC | |
by perlCrazy (Monk) on Jul 19, 2007 at 21:30 UTC | |
by jZed (Prior) on Jul 19, 2007 at 21:41 UTC | |
by perlCrazy (Monk) on Jul 19, 2007 at 21:50 UTC |