Cannot query the database SELECT max(position) as pos FROM sqlite_main_items WHERE order_id IS NULL