Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
hi, I have looked at previous posts and so included
use DBIx::Simple; use SQL::Abstract;
but to no avail. I have an INSERT statement in my code (table has 44 columns, first being an auto_increment id) that reads as (I've not included all 43 columns for brevity):
my $q = "INSERT INTO history (`Symbol`,`Company_Name`,`Last_Price`,... +...,`Mktcap`) VALUES (?,?,?,STR_TO_DATE(?,\'%m/%d/%Y'),TIME(?),?,?,?, +?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? +)";
When I only had 24 ?s following TIME(?)(making it a total of 29 values), I was getting the following error:
DBD::mysql::st execute failed: Column count doesn't match value count +at row 1 at line 62.
so, I went in and added 14 ?s towards the end to total it to 43 ?s (as in the above code) and now I get the following error:
DBD::mysql::st execute failed: called with 29 bind variables when 43 a +re needed at line 65.
can you please help me fix it.... I'm including the remaining code:
$sth = $dbh->prepare($q) or die $dbh->errstr; #the below includes 'id' which is auto_increment my @fields = ('id','Symbol','Company Name','Last Price',....,'Market-c +ap'); my @symbols = ('AA','C'); useRealtimeQueryFormat(); my @quotes = getquote(@symbols); while ($cc < 22222) { $cc++; foreach my $q (@quotes) { my @h = @{$q}; join("\t",@h),"\n"; my $c = @h; for ( my $i = 0 ; $i < $c ; $i++ ) { my $j = 1+ $i; $h[$i] =~ s/ +//; $h[$i] =~ s/ %//; $h[$i] = ($h[$i] eq 'N/A') ? undef : $h[$i]; } $sth->execute(@h); } }

In reply to column count error followed by too few bind variables by baperl

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2022-08-10 13:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found