I've got a couple of suggestions for you:
- localtime? - Perhaps you might be interested in something you have a little more direct control over - Date::Format maybe?
- prepare? How about do - When you expect to get rows out of your SQL statement one option is to prepare a Statement Handle Object first. Since you're doing an UPDATE, you really shouldn't be getting any rows back. Try
my $cur_time = time2str("%c", time) ;
$dbh->do("UPDATE Schedules SET Date = ? WHERE ID = ?",
undef, $cur_time, $id) ;
Errors may be caught in $dbh->errstr
- Placeholders - In the 2nd item I use question marks as placeholders. The format for do is $dbh->do($statement, \%attr, @bind_values);. You'll probably not need attrs, so undef should suffice. Placeholders are great because they make it easy to read the SQL and DBI will do the escaping of the values for you.
- Using prepare - If you still would like to use prepare I'd recommended using placeholders:
my $sth = $dbh->prepare("UPDATE Schedules SET Date = ? WHERE ID = ?");
my $cur_time = time2str("%c", time) ;
$sth->execute($cur_time, $id) ;
This may be prefered if you're going to be executing that $sth in a few places. Once $sth is prepared, it may be executed with different values multiple times.
Hope that helps =)
Update: BTW, I don't know what $id looks like, but if it's non-numeric, that's probably what UPDATE is barfing on: Needs escaping... but placeholders take care of that stuff =)
-Ducky