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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



ak08820
New User

Oct 18, 2009, 6:56 AM

Post #1 of 2 (449 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.

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


The update takes place as follows.

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

eval
{
$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/ODBC.pm 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.

Thanks


FishMonger
Veteran / Moderator

Oct 18, 2009, 8:20 AM

Post #2 of 2 (445 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

Code
$stmt{'SetKBBankLastNotifyDate'}

and then do

Code
$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