B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
DELETE FROM <table> WHERE rowid = a AND refcount - 1 = 0

IF @@ROWCOUNT = 0
    UPDATE <table> SET refcount = refcount - 1 where rowid = a

Is conditional statements allowed in sqlite?

No. Furthermore, SQLite does not support batches (sequences of statements), except in the body of a trigger. If you need to implement such a sequence in your program, sqlite3_changes() is a programmatic equivalent of @@ROWCOUNT.

Note that, in this particular case, you don't need the check at all. If the row has a rowcount of 1, then DELETE statement will delete it, then UPDATE statement run unconditionally will be a no-op (since no row meets the condition).

Igor Tandetnik

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

Reply via email to