Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Perl-Sensitive Sunglasses
 
PerlMonks  

Strange Execute Issue from PERL

by LHowell (Initiate)
on May 07, 2011 at 13:53 UTC ( #903554=perlquestion: print w/ replies, xml ) Need Help??
LHowell has asked for the wisdom of the Perl Monks concerning the following question:

Hey Perl Monks, I am really stuck! I have a Perl program that executes the following code snippet:
$InsertIntoMetar = <<SQL; REPLACE INTO Metar SELECT *,NULL FROM Deduped_Metars_No_Errors a; SQL .............. $sth = $dbh->prepare($InsertIntoMetar) or die "Can't prepare $InsertIntoMetar: $dbh->errstr\n"; $rv = $sth->execute + ##Insert into production Metar table. or die "can't execute the query: $sth->errstr";
The script dies with the following on the command line:
can't execute the query: DBI:: st=HASH(0x1a07924)-> errstr at Load_Met +ar_New1.pl line 600. Line 600 is the line that contains the $rv = $ +sth->execute shown above.
The interesting thing is that I can cut and paste the SQL contained in the prepare portion of the $LoadIntoMetar into a SQLYog window and it executes just fine!! Thoughts Anyone?

Comment on Strange Execute Issue from PERL
Select or Download Code
Re: Strange Execute Issue from PERL
by Corion (Pope) on May 07, 2011 at 14:01 UTC

    What else do you expect?

    As an idea, consider changing your code to:

    ... $rv = $sth->execute ##Insert into production Metar table. or die "can't execute the query: " . $sth->errstr; # ^^^^^^^

    That way, you'll see what your DBD things is the error cause and what it gives you as error message.

      I can not see what it is taht you are suggesting that I change my code to. It isn't being displayed in the reply!

        You currently have:

        $rv = $sth->execute or die "can't execute the query: $sth->errstr";

        I suggest that you change it into

        $rv = $sth->execute or die "can't execute the query: " . $sth->errstr;

        ... so that you see the actual error message from your database driver.

        If you look at the error message you got until now, you see DBI:: st=HASH(0x1a07924)-> errstr in there, which is much less informative than the actual return value of ->errstr.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://903554]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (21)
As of 2013-05-24 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (509 votes), past polls