in reply to Re: Strange Execute Issue from PERL
in thread Strange Execute Issue from PERL

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!

Replies are listed 'Best First'.
Re^3: Strange Execute Issue from PERL
by Corion (Patriarch) on May 07, 2011 at 21:37 UTC

    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.

      I made the change as follows: $sth = $dbh->prepare($InsertIntoMetar) or die "can't execute the query: " . $sth->errstr; I got the same result as before! I'm thinking that this has to be do some "user" or "pass" issue but that doesn't seem possible since I "prepare" and "execute make statements against tables in this database in the same script prior to the one that is causing me trouble. I create tables "Like" metar numerous times and do many "alters" and "drops". This is the first time I actually try to update "metar" though! Hope this helps! I am sure this is going to turn out to be something that is going to make me look VERY silly! Thoughts?

        I'm sorry. I quickly edited my node after posting it. First I had the ->prepare statement, but I then changed it to the ->execute statement. Please do make that change as well to your code.

        As general advice, I feel that two points might improve the quality of responses you get from us:

        First, please do take the time to learn how to format your nodes properly and how to mark text and code. It will make your nodes much more readable than the wall of text they currently appear as.

        Second, you might want to try to understand what I'm doing and suggesting here, and try to apply these changes to other parts of your code yourself. Retrieving as much information about the error case as possible is important before trying to remedy the error cause. Your descriptions about what you do don't seem to relate to the error cause at all. You haven't told us what database you are using, you haven't shown a self-contained program that replicates the problem. It seems to me that you don't know much about the code you are running. This is not a problem per se, but it means that you will need to familiarize yourself with the code much more before guessing about where the problems lie and what causes them. If you take more care to eliminate the non-Perl issues like database permissions, and put some effort into presenting a self-contained case, you will find that people are far more likely to try it and to give you answers relevant to your problem.