UPDATE wit LIMIT

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
m227
Posts: 59
Joined: Mon 06 Aug 2007 12:41

UPDATE wit LIMIT

Post by m227 » Tue 23 Feb 2016 10:49

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UPDATE wit LIMIT

Post by AlexP » Tue 23 Feb 2016 11:48

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)

Post Reply