On Mon, 15 Apr 2002 19:10:22 -0400
"Thomas A. Lowery" <[EMAIL PROTECTED]> wrote:
> What exactly are you asking about? errstr is normally only defined
> when an error occurs.
>
> You can force an error:
>
> use warnings;
> use strict;
> use DBI;
> use Carp;
>
> my $dbh = DBI->connect( 'dbi:Pg:dbname=template1', undef, undef,
> {PrintError => 0, RaiseError => 0} ) or croak $DBI::errstr;
>
> my $sth = $dbh->prepare( 'select fred from nothing' );
>
> croak $dbh->errstr if ($dbh->err);
>
> $sth->execute;
>
> croak $sth->errstr if ($sth->err);
>
> exit;
>
> END { $dbh->disconnect if defined $dbh }
>
>
> On Mon, Apr 15, 2002 at 04:18:08AM -0500, GB Clark wrote:
> > Any time I call errstr either as a method or variable
> > all I get is the err code. ONE time I did get the right
> > string, but for the life of me, I can't figure out why I
> > can not get now.
> >
> > Any ideas?
>
> --
> Thomas A. Lowery
> See DBI/FAQ http://xmlproj.dyndns.org/cgi-bin/fom
>
Here is an example right out of my code, maybe I'm doing something wrong here...
[SNIP]
$dbh->do($insert);
if($DBI::err) {
my $error = $DBI::errstr;
CloseDBConnection($dbh);
DBError "AddUser - do - $error";
}
[SNIP]
First I perform the operation,
then I check to see if there was an error and if so I capture the
error code, close the connection and call my error routine.
The problem is that as an example I try to insert duplicate values into
a unique index, all I see is "AddUser - do - 7" instead of the error string
telling me that I'm trying to insert a dup value. Even if I change the
$DBI::errstr/$DBI::err to $dbh::err/$dbh::errstr I see the same thing.
I've got printerror and raiseerror set to zero.
Any ideas?
Thanks!
GB
--
GB Clark II | Roaming FreeBSD Admin
[EMAIL PROTECTED] | General Geek
CTHULU for President - Why choose the lesser of two evils?