SQLite Forum

how to check update statement really modify a record
Login
> is there any method to check the update statement is really modify a record ?

Do you mean if it "has modified" a record, or if it "will modify" a record?

If you simply want to know if a record was modified or not, the page posted by others is perfect.

If you want to know if it WILL modify a record, or if there was definitely a record to modify, you have to issue two statements, the first might be:

```
SELECT 1 FROM table WHERE id=911 AND column_name<>value;
```

If that returns any row, then it means your update statement WILL modify the DB. No rows means it won't.

As far as understanding the case where:

> (no record that id equal to 911)

You really cannot get away from issuing:

```
SELECT 1 FROM table WHERE id=911;
```

Which is the only good way to know if id 911 exists in the table or not.

Another way to check AFTER the fact if an update succeeded (if needed), is to formulate this:

```
UPDATE table SET column_name=value WHERE id=911;
SELECT 1 FROM table WHERE id=911 AND column_name=value;
```

If the SELECT returns any rows, the UPDATE either succeeded or was not needed, but there definitely is a Row with that id and value now.


Good luck,
Ryan