3115 Error with SQLite

by Alexis Hope, 16 Jan 2011

Spoiler: Double quote string values in SQLite statements (Possible solution this error is raised by many misconfigurations).

With SQLite in Adobe AIR, I was running some initial tests to figure out a cleaver TRIGGER to UPDATE or INSERT appropriately.

So far I’ve been writing all my query’s in Flex, writing statements manually for instant feedback. I encountered the #3115 Error. Searching through google I see a lot of posts about this. The answer it seems is widely varied. Other possibilities include incorrect path to applicationStorageDirectory or invalid table names. My issue (to the best of my knowlodge) was a reserved word inside single quotes.

I was trying to insert Name Test as a value with single quotes. SQLite will sometimes bend quoting rules I’m assuming while single quoted Name was being evaluated as a reserved word. It is a reserved word by SQL standards, although not present in the SQLite keyword list…

My answer: Double quote values

INSERT INTO Testtable (ID, Name) VALUES (1, "Name Test")

I was single quoting ‘Name Test’ (and so were the other examples I saw). I only encountered this error when typing statements in the console. Using parameters in AS3 are great and take care of it for you. Also single quotes worked fine when executing the query from Flex. I can’t find a documented cause of the error only that switching quotes fixed it for me.

I’ll post the TRIGGER if sucessful