CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
DBI Issue - Can't mix placeholder styles


New User

Oct 18, 2009, 6:56 AM

Post #1 of 2 (1020 views)
DBI Issue - Can't mix placeholder styles Can't Post

I am trying to debug a script that fails to update a MS Access database.
The update statement is as follows.

my($data_bank_date_field) = 'CustomInfo3'; 
$stmt{'SetKBBankLastNotifyDate'} = sprintf('UPDATE userdetails SET %s = ? WHERE UserIndex = ?', $data_bank_date_field);

The update takes place as follows.

if ($users_to_mail{$_}->{'MailKBBank'}) 

$dbh->do($stmt{'SetKBBankLastNotifyDate'}, undef, $now, $users_to_mail{$_}->{'UserIndex'});
logw(1,sprintf("Failure to mark user %s as e-mailed, %s", $users_to_mail{$_}->{'UserID'}, $@)) if $@;

On being executed, I see an error as follows in the log.
Failure to mark user MC001234 as e-mailed, Can't mix placeholder styles (3/1) at C:/Perl/lib/DBD/ line 134.

This is puzzling as the DBI code uses only ? as the placeholders. :N or :Name are not used/mixed.

I also do not understand the use of undef in the above.

Please tell me how I can fix this error.


Veteran / Moderator

Oct 18, 2009, 8:20 AM

Post #2 of 2 (1016 views)
Re: [ak08820] DBI Issue - Can't mix placeholder styles [In reply to] Can't Post

Is this an AlepoRBS database?

Why are you using sprintf? In this code all it does is add unnecessary syntax, which equates to clutter.

Would I be correct in the assumption that this code is within a loop that processes each UserIndex?

If so, then it would be more efficient to prepare the statement where you're assigning


and then do

$sth->execute($now, $users_to_mail{$_}->{'UserIndex'});

in the eval block.

Doing that should solve your error.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives