S
Stephen Lake
Hi all,
i am having a small problem with rows in the DBD::mysql module.
more specifically, what I am trying to do is to insert a value in a mysql
table ONLY if it does NOT exist in there already. Now I know the queries are
working ok but its the num rows thats not evaluating properly and thus I am
getting duplicates in the table that I do not want.
I have read the DBD::mysql doc at CPAN but that didn't solve my problem and
have read the perldoc specifically the sections on Operators and Control
Structures and everything here seems to be in accordance with how its
suppose to be done.
Here is a piece of code that I have and that the problem is manifesting
itself in:
======================================
my $qb = $dbh->prepare("SELECT * FROM stockIndex WHERE pSymbol='$sym'");
$qb->execute;
if($qb->rows()==0) {
if(!$dbh->do("INSERT INTO stockIndex(pSymbol) VALUES('$sym')"))
{
print $dbh->errstr;
}
}
$qb->finish();
=======================================
Can anyone please point out the error in here or give me any idea of what is
going wrong?
Thanx
Steve
i am having a small problem with rows in the DBD::mysql module.
more specifically, what I am trying to do is to insert a value in a mysql
table ONLY if it does NOT exist in there already. Now I know the queries are
working ok but its the num rows thats not evaluating properly and thus I am
getting duplicates in the table that I do not want.
I have read the DBD::mysql doc at CPAN but that didn't solve my problem and
have read the perldoc specifically the sections on Operators and Control
Structures and everything here seems to be in accordance with how its
suppose to be done.
Here is a piece of code that I have and that the problem is manifesting
itself in:
======================================
my $qb = $dbh->prepare("SELECT * FROM stockIndex WHERE pSymbol='$sym'");
$qb->execute;
if($qb->rows()==0) {
if(!$dbh->do("INSERT INTO stockIndex(pSymbol) VALUES('$sym')"))
{
print $dbh->errstr;
}
}
$qb->finish();
=======================================
Can anyone please point out the error in here or give me any idea of what is
going wrong?
Thanx
Steve