sqlite_modern_cpp icon indicating copy to clipboard operation
sqlite_modern_cpp copied to clipboard

[question] about data update wrapper

Open fawdlstty opened this issue 3 years ago • 2 comments

How many rows has modified by an update command? What value when auto_increment of primary key after inserted?

fawdlstty avatar Feb 24 '22 03:02 fawdlstty

Assuming sqlite::database db(...);:

How many rows has modified by an update command?

auto changed = db.rows_modified();

What value when auto_increment of primary key after inserted? If the primary key is a INTEGER PRIMARY KEY (aka an alias for the rowid), then you can use

auto last_id = db.last_insert_rowid();

Otherwise I don't think that sqlite makes that information available. (But if you want to use an auto_increment primary key you normally want to make it a rowid alias anyway)

zauguin avatar Feb 24 '22 06:02 zauguin

Thank's, I'll try.

fawdlstty avatar Feb 24 '22 07:02 fawdlstty