Page 1 of 1

UPDATE wit LIMIT

Posted: Tue 23 Feb 2016 10:49
by m227
Dear Sirs,
Is it allowed in your implementation to enrich update with ORDER and LIMIT clauses like:

Code: Select all

    SQL.Add('UPDATE FileWork SET finish = :finish ');
    SQL.Add('WHERE (path = :path) AND (finish IS NULL) ');
    SQL.Add('ORDER BY id DESC LIMIT 1');  // unsupported anyhow
Michal

Re: UPDATE wit LIMIT

Posted: Tue 23 Feb 2016 11:48
by AlexP
Such construct is available only if the sqlite3.dll library is built with the key: SQLITE_ENABLE_UPDATE_DELETE_LIMIT. It also requires a separate generated file parse.c, not ready sources of amalgamation.

You can build such a library. We don't plan to add such functionality in Direct Mode.

P.S. You can use a sub-query to achieve a similar result.

Code: Select all

UPDATE FileWork SET finish = :finish
WHERE id in (select id from FileWork where (path = :path) AND (finish IS NULL) ORDER BY id DESC LIMIT 1)