I have 3 different arrays in Perl (namely A, B and C). Now, I have a table in mysql which also has 3 fields.
What I am trying to do is get all the contents of array A in first field of mysql table, contents of array B into second field and so on. I tried doing this using foreach loops but it works fine for the first array but does not insert anything for the second and third array.
The code is used is as below:
foreach my $a (@a) {
my $sql = "insert into es(a) VALUES(\"$a\")";
my $sth = $dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";
}
foreach my $b (@b) {
my $sql = "insert into es(b) VALUES(\"$b\")";
my $sth = $dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";
}
and similarly for third. The column a of the table gets populated correctly but there is no data for column b and c in the table. What am I doing wrong.