SQLite – compare null values


this is a quick post describing issue I have found when using SQLite in flash. I’ve tried to fetch some rows using following snippet, but couldn’t get correct results. Then after digging on the net I have found that there is a different syntax to compare null values. The problem was in comparing values that sometimes can be null.

The idea was to get how many empty values I have in the database, the result was always 0. I have start with plain text query (no parameters), but it didn’t worked as I’ve found on the SQLite page you can’t just use equal to compare NULL values, you have special syntax IS NULL or IS NOT NULL.

Continue reading

SQLite: Calculate difference between datetime fields

If you want to easily get elapsed time between datetime fields in SQLite you may want to take a look at following snippet:

         ) AS real
      )/60/60 AS elapsed
FROM some_table AS t;

Table some_table contains 2 columns named start and finish both datetime type. Result will contain value in hours.

AIR and SQLite transaction issues

Nice thing about SQLite in Adobe AIR are transactions, you start them with begin method of SQLConnection instance and then finish with rollback or commit methods. Problem occurs when you start transaction with default arguments and then try to stop it without any changes being made.
Continue reading

‘unique’ as column name in SQLite table and SQLError


I have just learned that “unique” is not a good name for column name when creating table. If you try to use it then you will get following meaningless (at least to me) error:

SQLError: 'Error #3115: SQL Error.', details:'near 'BOOLEAN': syntax error'

So whenever you will have similar error and at first glimpse everything looks fine then check your column IDs.