![]() A usecase is a self-contained piece of code that demonstrates your issue in the least possible number of lines. When you post a question to the Q&A, you will receive much more accurate answers more quickly by posting a proper "usecase". Try this out, and post your updated code if you can't get it to work. Ti.API.info(cityId + ' ' + cityName + ' ' + cit圜ontinent) Var cit圜ontinent = cityWeatherRS.fieldByName( 'continent') Var cityName = cityWeatherRS.fieldByName( 'name') ![]() Var cityId = cityWeatherRS.fieldByName( 'id') Var myKey = cityWeatherRS.fieldByName( 'mykey') Var cityWeatherRS = db.execute( 'SELECT ROWID AS mykey,id,name,continent FROM city') Although I haven't tried it myself, I suggest that you could retrieve the unique ROWID key value using the following code (not tested): var db = Ti.Database.open( 'weatherDB') Thus, combining these two approaches, there is no need to specify any value, even null, for the autoincrement field when inserting data. See the example in the Storing Data section of the Working with Local Data guide. There is a recommended way to insert data using the Titanium API. SQLite's support for autoincrement is explained in the official SQLite documentation. Thanks for any help on resolving that error. The application has crashed with an unhandled exception. SQLite error: ' constraint failed' for 'INSERT INTO records (Id, Title, Description, Value) VALUES (NULL, "Title", "Description", "12345") ' ![]() This is the error msg from the console that is thrown with the above statement: 23:51:01.092 FBKT Error occurred calling next on a PLSqliteResultSet. I also made sure, that the database is fully closed (SQLite Manager is temrinated). While I can successfully insert that statement in (Firefox) SQLite Manager, I get an error/app crash in the simulator. My table looks like: CREATE TABLE "records" ( "Id" Integer PRIMARY KEY NOT NULL, "Title" Varchar NOT NULL, "Description" VarChar, "Value" varchar NOT NULL, "Created" TimeStamp NOT NULL DEFAULT ( CURRENT_TIMESTAMP), "GeoLat" VarChar, "GeoLon" VARCHAR) execute( 'INSERT INTO records (Id, Title, Description, Value) VALUES (' + insert entry into database var result = db. Var db = Ti.Database.install('db/records.sqlite','records') My code actually looks like // open database I have tried all variations executing the query. DB query failing in TI (while working in SQLite Manager)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |