Count the results of an SQLite update

Hi,

One of my programs can perform a mass delete or updates in SQLite. I’d like to tell the user the number of rows updated or deleted. SQLite records this information and you can retrieve it with

int sqlite3_changes(sqlite3*);

However not being anything like an SQL expert, how do I get that back into Xojo.

Thanks
Jack

You’ll have to do a separate query for now using the same where clause. I also suggest making a feature request though.

Thanks.

Have created a feature request. #80702

jack

Using

SELECT changes();

Does same as

int sqlite3_changes(sqlite3*);

So you perfectly can do it without any feature request or any new feature added to Xojo.

4 Likes

is there the same function for postgresql ? I didn’t find one.

Thank you, I will give that a try.

Jack

Yes there is, see:

You need to wrap your update statement in a PLPGSQL-function. I’m doing that a lot and it works great.

Why not use the RETURNING function:

SQL = "DELETE FROM myTable WHERE myField = 'Something' RETURNING id"

You can use RETURNING with UPDATE as well.

That works. Thank you.