webSQL AUTOINCREMENT not working (Different from the one in search)
android, cordova
Solution
Try using this:
tx.executeSql('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, value VARCHAR)');
In webSql (sqlite) PRIMARY KEY automatically increments unless you pass values. Additional information here: http://sqlite.org/autoinc.html
Problem
Learning phonegap to write a basic app for Android. Using WebSQL for this reason, I know it's deprecated but it's just for an Android phone and no scaling so not going to bother with things like polyfills at this time. Just trying to get auto_increment to work before I even get started on things like callback handlers, the basis for the code: ``` var db = openDatabase('test', '1.0', 'Test', 10 * 1024 * 1024); db.transaction( function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS test (id INTEGER AUTOINCREMENT, value VARCHAR)'); } ); $(function(){ $('#test').click(function(){ alert('click'); db.transaction( function (tx) { tx.executeSql('INSERT INTO test (value) VALUES (?)', ["testValue"]); } ); }); }); ``` Tried using things like the default keyword, but nothing seems to work. If I add a value for the ID column it works fine. EDIT Here's code trying it out, inserts nothing. ``` var db = openDatabase('test', '1.0', 'Test', 10 * 1024 * 1024); db.transaction( function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, value VARCHAR)'); } ); $(function(){ $('#test').click(function(){ alert('click'); db.transaction( function (tx) { tx.executeSql('INSERT INTO test (value) VALUES (?)', ["testValue"]); } ); }); }); ```