perlquestion
baperl
hi,
I have looked at previous posts and so included
<code>
use DBIx::Simple;
use SQL::Abstract;
</code>
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):
<code>
my $q = "INSERT INTO history (`Symbol`,`Company_Name`,`Last_Price`,......,`Mktcap`) VALUES (?,?,?,STR_TO_DATE(?,\'%m/%d/%Y'),TIME(?),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
</code>
When I only had 24 ?s following TIME(?)(making it a total of 29 values), I was getting the following error:
<code>
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at rtd.pl line 62.
</code>
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:
<code>
DBD::mysql::st execute failed: called with 29 bind variables when 43 are needed at rtd.pl line 65.
</code>
can you please help me fix it....
I'm including the remaining code:
<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-cap');
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);
}
}
</code>