1

My table looks something like

table (id, attribute, value, expires, static)

I'd like to be able to update this table for new values of value, expires or static when an entry for an id/attribute pair that already exists. I would like to create a new entry for every new id/attribute pair and every new id.

I am new at using sqlite and have seen a few posts similar to my problem like SQLite - UPSERT *not* INSERT or REPLACE but they do not fully address what I'm trying to do. Maybe its my approach and I need a different table format.

Please let me know your thoughts/suggestions.

Community
  • 1
  • 1
awpitt13
  • 145
  • 9

1 Answers1

1

Just put the logic into your program:

bool ok = query.exec("UPDATE ...");
...
if (query.numRowsAffected() == 0) {
    ok = query.exec("INSERT ...");
    ...
}
CL.
  • 158,085
  • 15
  • 181
  • 214