On 11/29/05, Jeff Boes <suppressed> wrote:
> What techniques do others use in catching DBI errors within a Perl
> block? For instance,
>
> [perl table=mytable]
> my $dbh = $Sql{mytable};
> $dbh->do(q{INSERT INTO mytable (a, b, c) VALUES (?, ?, ?)}, ...
> [/perl]
>
> I have not yet found any way to catch an INSERT error (e.g., bad data
> type, missing parameter, foreign key violation, unique constraint
> violation).
You use do when you don't care about what is returned, when you care
you must "do" more work...
---untested code---
my $dbh = $Sql{mytable};
my $sth = $dbh->prepare(q{INSERT INTO mytable (a, b, c) VALUES (?, ?, ?)});
$sth->execute() or die("ERROR!: " . $sth->errstr);
Hope that helps you in the right direction :)
--
Jeff Fearn
"Postmodernism: Once more without feeling." -- Geoffrey Nunberg
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.