title: Why is SQLite not incrementing my primary key?
body: <p>Here is my table,</p>
  
  <pre><code>sqlStmt = [ [ NSString stringWithFormat:@"Create Table %@  (recordNo INTEGER PRIMARY KEY AUTOINCREMENT, noOfPlayer  INTEGER, smallBlindAmt INTEGER, bigBlindAmt INTEGER , startingChips INTEGER, roundTimer INTEGER) " , SETTINGS_TABLE  ] StringUsingEncoding:NSUTF8StringEncoding ] ;
  </code></pre>
  
  <p>insert query,</p>
  
  <pre><code>sqlStmt = [ [ NSString stringWithFormat: @"insert into %@ values (NULL,%d, %d ,%d ,%d ,%d )" , strTableName ,noOfPlayers, SmallAmt, BigAmt, StartingChips, RoundTime ] UTF8String ] ;
  </code></pre>
  
  <p>get last record's record id,</p>
  
  <pre><code>lastRecordNo = sqlite3_last_insert_rowid(dbObj);
  </code></pre>
  
  <p>The lastRecordNo is always 0, and I am unable insert another values because it gives the error primary key must be unique.</p>
  
  <p>I am unable to get the problem associated with it?</p>
  
  <p>How to fetch the last record id which is primary key and autoincrement.?</p>
  
  <p>Is there any problem in my insert query? </p>
  
  <p>Can anyone explain me with example create, insert and select queries where primary is an autoincrement?</p>