Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive


I am trying to accomplish what is normally a fairly simple SQL query, and having troubles getting it to work. My INSERT query works fine:

db.execute('INSERT INTO ' + tableName + ' (ID, DISPLAY ) VALUES(?,?)', displayOptionName, displayOptionValue);

But when I try the INSERT UPDATE version it doesn't work:

db.execute('INSERT INTO ' + tableName + ' (ID, DISPLAY ) VALUES(?,?) ON DUPLICATE KEY UPDATE DISPLAY = ?', displayOptionName, displayOptionValue, displayOptionValue);

I dare say I have just typed something wrong, but it is a little frustrating, the Kitchen Sink 3 examples dont seem to show this query in all it's glory. Is there a better way to get around the problem?

— asked April 9th 2010 by Dan Duke
  • android
  • db
  • insert
  • query
  • sql
  • update
  • win32

1 Answer

  • Ok, for others, a good link to use is: http://www.sqlite.org/lang_insert.html

    Just make sure you set up your database fields rrectly in the first place (PRIMARY KEY)

    — answered April 15th 2010 by Dan Duke
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.