Ian Harisay wrote:
Try "SELECT * FROM a1 WHERE custnum = ?"
Thank you Ian and Ted
That is not the problem, I had previously used a single "=" and went to
"==" when it didn't work, tried again this morning - still doesn't work.
SQLite documentation says either is acceptable. A little more
information, the substitution value is a string - dbi docs say the
placeholder does not need to be quoted, looking with "ptkdb", $rowref
remains "undef" so I am assuming the substitution is not made at the
"execute" statement and the result is a SQL search for a "null" value in
the "custnum" field which returns nothing.
John
-----Original Message-----
From: John [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 10, 2005 10:40 PM
To: dbi-users@perl.org
Subject: select placeholder
Hi
Can anyone see the error in the following code. It has to do with the
placeholder in the select statement. Substitution fails to occur at the
"$sth1->execute..." statement script dies at "while (my $rowref...". If
I replace the placeholder with a literal it works as expected.
[code]
#
# open database
#
my $dbh = DBI->connect("dbi:SQLite:$db1","","")
or die "couldn't connect to database: " . DBI->errstr;
#
# sql statements
#
my $st1 = "SELECT * FROM a1 WHERE custnum == ?";
my $sth1 = $dbh->prepare($st1) or die "couldn't prepare... " .
DBI->errstr;
my ($asset, $custnum, $branch, $customer, $address, $town, $postcode);
my ($line, $aline, $cline, @assets, @customers, @lines, @cust2,
@unigas); my ($done, $record, @records, %seen, $cnt, $ii, $best,
@updates);
#
# build list of duplicate details
#
#while (not defined $done)
{
$custnum = shift @duplist;
redo if int($custnum) == 0;
$sth1->execute($custnum) or die "couldn't execute... " .
DBI->errstr;
while (my $rowref = $sth1->fetchrow_arrayref) {
($asset, $custnum, $branch, $customer, $address, $town,
$postcode) = @$rowref;
[/code]
--
Regards
John McMahon <[EMAIL PROTECTED]>
--
Regards
John McMahon ([EMAIL PROTECTED])
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 9/12/2005