Search code examples
sqlitecoronasdk

update sqlite database for existing primary key


I only need to update one sqlite database entry (this is inside Corona SDK but the commands are the same)

'place' is Table name and xcor is first column in my database. I have tried both of the following but none of them updates that particular entry.

UPDATE place SET xcor = testvalue[3] WHERE Id=databaseid;

[INSERT OR REPLACE INTO place VALUES (databaseid, ']]..testvalue[1]..[[',']]..testvalue[2]..[[',']]..testvalue[3]..[['); 

The command insert works fine with parameters for entering a new entry however I need to update an existing entry.


Solution

  • The databaseid needs to be wrapped like thi.

    UPDATE place SET xcor = testvalue[3] WHERE Id=']]..databaseid..[[';