尝试修改 sqlite3 插入以返回 PK。 不确定如何使用 sqlite3 专门执行此操作

Trying to modify an sqlite3 insert to return the PK. Wasn't sure how to do it with sqlite3 specifically

本文关键字:sqlite3 何使用 执行 操作 不确定 修改 插入 PK 返回      更新时间:2023-10-16

>我试图在表中插入一些数据,但我不确定什么标志允许我返回主键。我相信我记得MSSQL使用RETURNING,而其他一些人在最后使用了RETURNS。

有人可以帮忙附加它吗?

我正在尝试返回 TABLEA.a,我的查询和设计如下所示:

sqlite3 *db;
sqlite3_open("...",&db);
std::string query;
query = "insert into TABLEA (b,c,d,e) values (@b,"@c",@d,@e);"; 
            //^--this needs to be modified.
sqlite3_stmt *sqlstmt;
int rc;
rc = sqlite3_prepare_v2(db, query.c_str(), 01, &sqlstmt, 0);
sqlite3_step(sqlstmt);
int ID;
ID = sqlite3_column_integer(sqlstmt,0);

你试过sqlite3_last_insert_rowid吗?