pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeremy Buchmann <jeremy@wellsgaming.com>
To: Zachary Beane <xach@xach.com>
To: pgsql-interfaces@postgresql.org
Subject: Re: DBD::Pg or DBI breakage?
Date: Thu, 24 May 2001 08:32:54 -0700
Message-ID: <B73277B6.2EB5%jeremy@wellsgaming.com> (raw)
In-Reply-To: <20010523163432.I18366@xach.com>

> I've been having trouble getting the proper value of $handle->errstr
> or $DBI::errstr. For some reason, it's always giving the scalar 7 back
> rather than an informative error message. Here's an script and output:
> 
> --- foo.pl ---
> #!/usr/bin/perl
> 
> use DBI;
> my $dbh = DBI->connect("dbi:Pg:dbname=template1", "xach", undef);
> 
> my $sql = "bogus sql goes here";
> my $sth = $dbh->prepare($sql);
> $sth->execute() or die $sth->errstr;
> 
> my ($result) = $sth->fetchrow_array();
> 
> $sth->finish;
> 
> print $result, "\n";
> $dbh->disconnect();
> --- end ---
> 
> When run, it prints out this:
> 
> $ perl foo.pl 
> DBD::Pg::st execute failed:  at foo.pl line 8.
> 7 at foo.pl line 8.
> Database handle destroyed without explicit disconnect.
> 
> Now, I'm not surprised at the "database handle destroyed..." part, but
> I can't figure out why i'm getting "7 at foo.pl" and a blank message
> in the execute failed string. Any ideas?

Try disabling automatic error checking...after the call to DBI->connect, do
this:

$dbh->{PrintError} = 0;

-- Jeremy  [jeremy@wellsgaming.com]




view thread (3+ messages)  latest in thread

Message-ID: <B73277B6.2EB5%jeremy@wellsgaming.com>
Permalink:  ../B73277B6.2EB5%25jeremy@wellsgaming.com/
Also on:    postgresql.org/message-id/B73277B6.2EB5%jeremy@wellsgaming.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jeremy@wellsgaming.com, xach@xach.com
  Subject: Re: DBD::Pg or DBI breakage?
  In-Reply-To: <B73277B6.2EB5%jeremy@wellsgaming.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox