Suraj,

Don't use the same database connection in multiple threads. Each thread
should use its own connection. Then last insert rowid is predictable.

e


On Wed, Apr 1, 2015 at 1:10 PM, Kumar Suraj <surajnitk at gmail.com> wrote:

> Hi Richard.. this wont work for me due to following reason.
>
> If a separate thread performs a new INSERT
> <https://www.sqlite.org/lang_insert.html> on the same database connection
> while the sqlite3_last_insert_rowid()
> <https://www.sqlite.org/c3ref/last_insert_rowid.html> function is running
> and thus changes the last insert rowid
> <https://www.sqlite.org/lang_createtable.html#rowid>, then the value
> returned by sqlite3_last_insert_rowid()
> <https://www.sqlite.org/c3ref/last_insert_rowid.html> is unpredictable and
> might not equal either the old or the new last insert rowid
> <https://www.sqlite.org/lang_createtable.html#rowid>.
>
> On Tue, Mar 31, 2015 at 6:23 PM, Richard Hipp <drh at sqlite.org> wrote:
>
> > https://www.sqlite.org/c3ref/last_insert_rowid.html
> >
> > On Tue, Mar 31, 2015 at 9:19 PM, Kumar Suraj <surajnitk at gmail.com>
> wrote:
> >
> > > Hi
> > >
> > > I am using sqlite C interface for inserting data in the table. The
> > primary
> > > key is a 64 bit integer which i need to auto-increment and get
> populated
> > > automatically as we do not provide that value in insert statement. Is
> > there
> > > a way i can get the autoincremented value for each row inserted when
> > ever i
> > > execute my insert.
> > >
> > > -Suraj
> > > _______________________________________________
> > > sqlite-users mailing list
> > > sqlite-users at mailinglists.sqlite.org
> > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> > >
> >
> >
> >
> > --
> > D. Richard Hipp
> > drh at sqlite.org
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users at mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to