On Apr 14, 2008, at 10:40, Jeff Pang wrote:
On Mon, Apr 14, 2008 at 10:35 PM, Pat Rice
<[EMAIL PROTECTED]> wrote:
Hi all
I'm looking for some good ideas on trouble shooting SQL.
as in I have wrote thsi code, but I wondering if there is any way we
can a debug level, so that it would tell me if the query failed.
eg.
my $sql = q/SELECT Account,Last_Name,First_Name,Email_Address FROM
prospects WHERE Email_Address='?'/;
follow this you could try:
my $sth = $dbh->prepare($sql); # I think this works fine for your
statement
$sth->execute($email) or die $dbh->errstr; # execute it
$dbh->errstr will show you what's wrong in the execution.
Good luck.
You should also seriously consider adding RaiseError to your call to
connect. It will automatically die with the error message if any of
the methods fail. This is what my typical connect looks like:
my $dbh = DBI->connect($dsn, $user, $pass
{
PrintError => 0,
RaiseError => 1,
ChopBlanks => 1,
AutoCommit => 1,
FetchHashKeyName => "NAME_lc"
}
) or die "could not connect to $dsn as $user: ", DBI->errstr;
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/