Re: [sqlite] any command to find last rowid in a table

2010-02-08 Thread Shane Harrelson
Assuming you have a table with the following schema: CREATE TABLE t1 ( id INTEGER PRIMARY KEY AUTOINCREMENT, col2 REAL, col3 TEXT ); your C code *could* look something like the following: sqlite3_exec(db, "INSERT INTO t1 (col2,col3) VALUES (1.0,'row one');", 0, 0, 0);

Re: [sqlite] any command to find last rowid in a table

2010-02-08 Thread Vasanta
I understand "SELECT last_insert_rowid()" gives rowird, but I have to call these SQL statements in C language code, for that I have to sqlite3_prepare and sqlite3_step() calls, I am looking for sample of sqlite3_step, how that return the rowid, can I call like this: int rowid; sqlite3_stmt

Re: [sqlite] any command to find last rowid in a table

2010-02-08 Thread Kees Nuyt
On Mon, 8 Feb 2010 11:44:39 -0500, Vasanta wrote: > I tried to use this function call > "sqlite3_last_insert_rowid()" > calling from C language function, but it always returns zero, any idea?. > I have valid DB handle. The

Re: [sqlite] any command to find last rowid in a table

2010-02-08 Thread Vasanta
I tried to use this function call "sqlite3_last_insert_rowid()" calling from C language function, but it always returns zero, any idea?. I have valid DB handle. On Sat, Feb 6, 2010 at 9:25 AM, Vasanta wrote: > I found this

Re: [sqlite] any command to find last rowid in a table

2010-02-08 Thread Robert Citek
On Mon, Feb 8, 2010 at 9:31 AM, Vasanta wrote: > Can I use this function call in C code to return last rowid to be inserted?. On Fri, Feb 5, 2010 at 2:50 PM, Petite Abeille wrote: > Help Vampires: A Spotter’s Guide >

Re: [sqlite] any command to find last rowid in a table

2010-02-08 Thread Vasanta
Can I use this function call in C code to return last rowid to be inserted?. On Sat, Feb 6, 2010 at 9:25 AM, Vasanta wrote: > I found this C function call, this solved my problem, > sqlite3_last_insert_rowid(), > I just

Re: [sqlite] any command to find last rowid in a table

2010-02-06 Thread Vasanta
I found this C function call, this solved my problem, sqlite3_last_insert_rowid(), I just want to append new entries to existing imported table. On Sat, Feb 6, 2010 at 8:36 AM, Ibrahim A wrote: > Am 05.02.2010

Re: [sqlite] any command to find last rowid in a table

2010-02-06 Thread Ibrahim A
Am 05.02.2010 22:33, schrieb Vasanta: > Kittayya: > > My issue is, I already have imported table in the Database, there alreay > around 1000 records in that table where ROWID is from 1 to 1000, now system > generates new events, where ROWID again starts from beginning from 1, now > these new

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread P Kishor
On Fri, Feb 5, 2010 at 3:33 PM, Vasanta wrote: > Kittayya: > > My issue is, I already have imported table in the Database, there alreay > around 1000 records in that table where ROWID is from 1 to 1000, now system > generates new events, where ROWID again starts from beginning

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread German Escallon
Dude, Are you even reading what others have (very patiently) tried to explain you? Here's one more attempt. My advice (like everyone else in here) is to let SQLITE handle that for you with autoincrement. Asuming you don't take the advice, you can also try: int main() { ... .. . ... maxId =

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Vasanta
Kittayya: My issue is, I already have imported table in the Database, there alreay around 1000 records in that table where ROWID is from 1 to 1000, now system generates new events, where ROWID again starts from beginning from 1, now these new events are overwriting the earlier imported events by

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread P Kishor
I am top posting here because, (1) You are simply unable to articulate your own problem clearly, (2) you are not listening to the advice that you are getting, and (3) the quicker we put you on the right track the better it will be for everyone. First, if you have a table, you should have a

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Vasanta
I wroe this code to get ROWID, but if I assign output of sqlite3_step to an id, and assign that id, is OK?. const char *rowidSql = "SELECT max(ROWID)+1 "EVENTLOG_TBL ; const char *zSql; sqlite3_stmt * pStmt, pStmt2; /* This is added to run query to get ROWID */ rc =

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Shane Harrelson
As stated before, in general, you should not specify the ROWID on inserts, but instead, let the database engine choose it for you. This is true of most/all database engines. The syntax you're trying below is not supported. Indeed, even it were, max(ROWID) is the maximum ROWID *in use*. Trying

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Vasanta
This is my actual string, still not working: const char *replaceSql = "INSERT INTO "EVENTLOG_TBL \ "(_ROWID_, component, facilityId, logLevel,"\ "textMessage, binMessage) VALUES(?,?,?,?,?,?); SELECT max(ROWID) from EVENTLOG_TBL"; On

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Vasanta
Thanks jay. Can I combine like this: "INSERT INTO trends(UnitID,HeureTrends,DateTrends) VALUES(?,?,?);SELECT max(ROWID) FROM table-name"; or "INSERT INTO trends(UnitID,HeureTrends,DateTrends) VALUES(?,?,?);SELECT last_insert_rowid() AS [ID]"; On Fri, Feb 5, 2010 at 2:49 PM, Jay A. Kreibich

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Petite Abeille
On Feb 5, 2010, at 8:37 PM, Vasanta wrote: > I couldn't find, looklike lot of expert users here, throw me command quickly Help Vampires: A Spotter’s Guide http://slash7.com/2006/12/22/vampires/ ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread P Kishor
On Fri, Feb 5, 2010 at 1:35 PM, Roger Binns wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Vasanta wrote: >> command "SELECT rowid from table-name;"  gives all rows from 1 to 100 for >> total 100 rows, any command to get last rowid?. I need insert from last >>

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Vasanta
I couldn't find, looklike lot of expert users here, throw me command quickly On Fri, Feb 5, 2010 at 2:34 PM, P Kishor wrote: > On Fri, Feb 5, 2010 at 1:28 PM, Vasanta wrote: > > command "SELECT rowid from table-name;" gives all rows from 1 to 100 for >

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Vasanta wrote: > command "SELECT rowid from table-name;" gives all rows from 1 to 100 for > total 100 rows, any command to get last rowid?. I need insert from last > rowid onwards (if table already 100 records, need to insert from 101 > onwards)

Re: [sqlite] any command to find last rowid in a table

2010-02-05 Thread P Kishor
On Fri, Feb 5, 2010 at 1:28 PM, Vasanta wrote: > command "SELECT rowid from table-name;"  gives all rows from 1 to 100 for > total 100 rows, any command to get last rowid?. I need insert from last > rowid onwards (if table already 100 records, need to insert from 101 > onwards)

[sqlite] any command to find last rowid in a table

2010-02-05 Thread Vasanta
command "SELECT rowid from table-name;" gives all rows from 1 to 100 for total 100 rows, any command to get last rowid?. I need insert from last rowid onwards (if table already 100 records, need to insert from 101 onwards) ___ sqlite-users mailing list