diff options
author | drh <drh@noemail.net> | 2002-04-12 10:08:59 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-04-12 10:08:59 +0000 |
commit | c8d30ac10998ef532f368524fc6be4eac81f4a43 (patch) | |
tree | 9a8765eea0b168b5ec1260551b4381d5a90d34f6 /src/tclsqlite.c | |
parent | b04a5d8768573f2bd257ee1ef7caa7bb550bac40 (diff) | |
download | sqlite-c8d30ac10998ef532f368524fc6be4eac81f4a43.tar.gz sqlite-c8d30ac10998ef532f368524fc6be4eac81f4a43.zip |
Fix for bug #15: Add the sqlite_changes() API function for retrieving the
number of rows that changed in the previous operation. (CVS 526)
FossilOrigin-Name: 6e71493b9dc77d508c3ce90562766789e87e6d80
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r-- | src/tclsqlite.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index edf947655..045c18d78 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.30 2002/03/11 02:06:13 drh Exp $ +** $Id: tclsqlite.c,v 1.31 2002/04/12 10:08:59 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -268,10 +268,12 @@ 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", "last_insert_rowid", "timeout", 0 + "busy", "changes", "close", "complete", + "eval", "last_insert_rowid", "timeout", 0 }; enum DB_opts { - DB_BUSY, DB_CLOSE, DB_COMPLETE, DB_EVAL, DB_LAST_INSERT_ROWID, DB_TIMEOUT + DB_BUSY, DB_CHANGES, DB_CLOSE, DB_COMPLETE, + DB_EVAL, DB_LAST_INSERT_ROWID, DB_TIMEOUT }; if( objc<2 ){ @@ -320,6 +322,25 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ break; } + /* + ** $db changes + ** + ** Return the number of rows that were modified, inserted, or deleted by + ** the most recent "eval". + */ + case DB_CHANGES: { + Tcl_Obj *pResult; + int nChange; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + nChange = sqlite_changes(pDb->db); + pResult = Tcl_GetObjResult(interp); + Tcl_SetIntObj(pResult, nChange); + break; + } + /* $db close ** ** Shutdown the database |