http://qs321.pair.com?node_id=317764


in reply to 2Re: Can SQL be used without a database?
in thread Can SQL be used without a database?

I do not think that SQLite offers auto-incremented ID's for you.
The number one FAQ entry at http://www.sqlite.org/faq.html:
(1) How do I create an AUTOINCREMENT field.
Short answer: A column declared INTEGER PRIMARY KEY will autoincrement.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: 2Re: Can SQL be used without a database?

Replies are listed 'Best First'.
getting the SQLite incremented ID
by lachoy (Parson) on Dec 30, 2003 at 22:22 UTC

    ...and using the DBI func method will pull out the value for you after an insert:

    $dbh->do( q{ CREATE TABLE foo ( id integer not null primary key, name varchar(20) ) }); $dbh->do( "INSERT INTO foo ( name ) VALUES ( 'bar' )" ); print "ID of record: ", $dbh->func( 'last_insert_rowid' ), "\n";

    Chris
    M-x auto-bs-mode