On 22 Feb 2013, at 10:15pm, Frederick Wasti <[email protected]> wrote:

> From the documentation on sqlite3_exec(), it seems as if it should return
> SQLITE_OK (=0) upon processing a successful SQL query. However, I was a
> bit surprised to see that an SQL statement such as "UPDATE table1 SET
> site='Site1' WHERE site='garbage' (where garbage really is garbage, as in
> not being present in the database) results in an SQLITE_OK return.
> 
> I guess there are two ways of looking at this: On the one hand, the SQL
> statement cannot succeed, so the return should not be SQLITE_OK.

This is where you make your error.  If I say "I'll pay you $100 to paint every 
frog in my yard black." and there are no frogs in my yard, you're still going 
to claim the money, aren't you.  If I argue with you you'll just tell me I 
should have counted the frogs before making the offer.

So yes, a SQL statement succeeds even if it does nothing.  Exactly the same as

DELETE FROM customers WHERE name = "John Johnson"

succeeds even if John Johnson isn't a customer.

If you want an analogy between SQL and a programming language, consider what 
happens if I execute

LET B = 6

when B is 6.  Would you expect the programming language to give you an error 
saying "Statement cannot be executed because B is already 6." ?

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to