"Dennis Cote" wrote,


jose isaias cabrera wrote:


So, there is on way of doing it in one call/instruction as I previously exampled, correct? I will have to do them in many calls, correct?


Jose,

You can do it in one API call if you put all the update statements into a single string. You will probably also want to add a begin and end around the updates so they are all done atomically in the database. You can then pass this string containing multiple statement to sqlite3_exec() and it will execute all the statements one after the other.

UPDATE table SET
  ID = '88' if not = '88',
  parent = '1171291314642' if null,
  children = '',
  login = 'blah',
  notes = 'blah-blah' if null,
  status = 'o'
  WHERE ProjID = '88';

Would become

string sql  =   "begin;"
               "update table "
" set ID = '88', children = '', login = 'blah', status = 'o' " " where ProjId = '88';"
               "update table "
               "   set parent = '1171291314642' "
               "   where ProjID = '88' AND parent IS NULL;"
               "update table "
               "   set notes = 'blah-blah' "
               "   where ProjID = '88' AND notes IS NULL;"
               "commit;";
              int rc = sqlite3_exec(db, sql.c_str(), 0, 0, 0);

Each update must have the same condition, but it can set multiple fields. The sqlite3_exec() function will execute all the SQL statements in a string in one call.

None of these are working...

BEGIN;
UPDATE LSOpenJobs SET bdate = '2007-03-02' WHERE ProjID = '215' AND bdate IS NULL; UPDATE LSOpenJobs SET ddate = coalesce(ddate, '2007-03-05') WHERE ProjID = '215'; UPDATE LSOpenJobs SET edate = ifnull(edate,'2007-03-05') WHERE ProjID = '215';
COMMIT;

Any ideas?  If I just set them, they do work.

thanks,

josé

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to