SELECT statement, with condition for string value, where string value is not taken to quotes

Issue #2 invalid
Ivan Yakushchenko created an issue

If I do query like this: SELECT * FROM Sensors WHERE Type == %s, where %s is not in quotes, and equals to TypeA the following error is dropped: *Error 402860 occurred at SQLite.lvlib:Connection.lvclass:Prepare (pointers).vi on a temporary or in-memory database

SQLITE_ERROR(1): no such column: TypeA * But, this error message is not relevant, because Type is anyway after WHERE statement; so it is not clear, how this statement is parsed... Maybe, then it should be solved on dll level - because if after WHERE statement is text, which should be considered as "Column Name" - "Value" pair, then how it parsed TypeA as column name? Do you have some suggestions, please?

Thanks a lot!

Sincerely, kosist.

Comments (2)

  1. James Powell repo owner

    Text values in SQL must be enclosed in single quotes, otherwise it will be assumed to be a column name. "WHERE ColumnA == ColumnB" is a perfectly valid WHERE statement.

    BTW, rather than using string formatting codes like %s to enter text values, I suggest you use parameter binding: use "SELECT * FROM Sensors WHERE Type == ?” and then bind the text “TypeA”.

  2. Log in to comment