diff options
author | drh <drh@noemail.net> | 2002-01-16 21:00:27 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-01-16 21:00:27 +0000 |
commit | af9ff33ac1ac9234e03a668c83e674a5568686ee (patch) | |
tree | a03056b2c83391b438c7a6adfcac5f67da172739 /src/tclsqlite.c | |
parent | a297b5c3cfc980c28fe60889f25822f2cd5072f3 (diff) | |
download | sqlite-af9ff33ac1ac9234e03a668c83e674a5568686ee.tar.gz sqlite-af9ff33ac1ac9234e03a668c83e674a5568686ee.zip |
Added the last_insert_rowid API function. Improved documentation of
the random ROWID algorithm. (CVS 349)
FossilOrigin-Name: f74d61aaf3fec06cde2c4a6f1465f86ac9058ad2
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r-- | src/tclsqlite.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index a604afc08..541914161 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.28 2001/11/09 13:41:10 drh Exp $ +** $Id: tclsqlite.c,v 1.29 2002/01/16 21:00:27 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -268,10 +268,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *pDb = (SqliteDb*)cd; int choice; static char *DB_optStrs[] = { - "busy", "close", "complete", "eval", "timeout", 0 + "busy", "close", "complete", "eval", "last_insert_rowid", "timeout", 0 }; enum DB_opts { - DB_BUSY, DB_CLOSE, DB_COMPLETE, DB_EVAL, DB_TIMEOUT + DB_BUSY, DB_CLOSE, DB_COMPLETE, DB_EVAL, DB_LAST_INSERT_ROWID, DB_TIMEOUT }; if( objc<2 ){ @@ -425,6 +425,24 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } /* + ** $db last_insert_rowid + ** + ** Return an integer which is the ROWID for the most recent insert. + */ + case DB_LAST_INSERT_ROWID: { + Tcl_Obj *pResult; + int rowid; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + rowid = sqlite_last_insert_rowid(pDb->db); + pResult = Tcl_GetObjResult(interp); + Tcl_SetIntObj(pResult, rowid); + break; + } + + /* ** $db timeout MILLESECONDS ** ** Delay for the number of milliseconds specified when a file is locked. |