views:

223

answers:

1

I'm having trouble getting a prepared statement in sqlite3 to work. I'm working with Perl and the Perl DBD framework. Below is the code I use:

#This is a function I have defined
sub query($@){
    my $st = $db->prepare(shift);
    $st->execute(@_);
}

#And it is used like so
query("UPDATE rooms SET name = ?, SET capacity = ? WHERE id = ?", 
    $name, $capacity, $id);

When I try that, I get the following error:

DBD::SQLite::db prepare failed: near "SET": syntax error(1) at dbdimp.c line 
271 at database.pm line 80.

Why do I get that error? If I try it without using prepared statements, it works. Every other prepared statement in my application works, except that UPDATE query.

+9  A: 

Your query, using standard (and sqlite's) UPDATE syntax is

UPDATE rooms SET name = ?, capacity = ? WHERE id = ?

without a repeated SET

Vinko Vrsalovic