R
Reinhard Glauber
I have a sub called "insert".
In the main - Programm I call this subroutine. The Problem is, that I get an DB-Errormessage.
That's something I don't want. That's the reason why I tried to write the code with "eval".
The error occures, when there is a duplicate value.
The error is not the Problem. The Problem is, that I dont want Perl to write me all the time this Errorcode.
A simple "Error" is enough for me...
So look at the Code...
sub insert
{
........
eval {
$dbh = DBI->connect('DBI:mysq blabla');
my $sql = "INSERT INTO blabla";
my $sth = $dbh->prepare( $sql );
$sth->execute();
};
if (!$@) { $isok = "... ok\n";}
if ($@) {$isok = "Error\n";}
} # end of sub
$res = insert ($value);
print $isok;
Any Hints for a Perl-Newbie ??
Thanks a lot
In the main - Programm I call this subroutine. The Problem is, that I get an DB-Errormessage.
That's something I don't want. That's the reason why I tried to write the code with "eval".
The error occures, when there is a duplicate value.
The error is not the Problem. The Problem is, that I dont want Perl to write me all the time this Errorcode.
A simple "Error" is enough for me...
So look at the Code...
sub insert
{
........
eval {
$dbh = DBI->connect('DBI:mysq blabla');
my $sql = "INSERT INTO blabla";
my $sth = $dbh->prepare( $sql );
$sth->execute();
};
if (!$@) { $isok = "... ok\n";}
if ($@) {$isok = "Error\n";}
} # end of sub
$res = insert ($value);
print $isok;
Any Hints for a Perl-Newbie ??
Thanks a lot