[ABE.pm] DBI Q

Ricardo SIGNES rjbs-perl-abe at lists.manxome.org
Tue Nov 9 14:41:46 CST 2004


* Faber Fedor <faber at linuxnj.com> [2004-11-09T15:22:28]
> What's the Proper Way to grab an error from a DBI call?  I thought this
> would work:
> 
>  $dbh->do($stmt);
>  snd_msg("failure in LOAD DATA INFILE command. Error: $DBI::errstr")
>             if defined($dbh->err);
> 
> but that prints an error to STDOUT and dies, i.e. it never reaches
> snd_msg(). 

It dies, with RaiseError set to zero?

What about this:

	{
		local $dbh->{RaiseError} = 0;
		$dbh->do($stmt) or die("problem: " . $dbh->errstr);
	}

What does that do?

>  $dbh->do($stmt) or
>  snd_msg("failure in LOAD DATA INFILE command. Error: $DBI::errstr")
>             if defined($dbh->err);

That is the same as this:

	if (defined $dbh->err) {
		$dbh->do($stmt) or snd_msg("...");
	}

...which is surely not what you want.

-- 
rjbs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/archives/abe-pm/attachments/20041109/d00fe04d/attachment.bin


More information about the ABE-pm mailing list