SQLite Forum

select match though row does not exists
Login
You are misusing quotes. SQLite uses single quotes for string literals and double quotes for identifiers (sometimes, if there is no identifier, SQLite will assume you misused the quotes and silently accept a string literal in double quotes). The condition c="C" compares field c (case insensitive names) with itself, which is always true.

The "new" probem is interference from several connections to the same database file. Apparently the schema has been changed (column x renamed) between preparing and executing the select statement. Your error handling is questionable, as getting "no such column:x" is not indicative of a successful result but you are inserting the value anyway, which correctly results in a constraint failure.

Your new question is probably caused by not passing the database handle correctly between functions.