00 Votes

SQLite: Error "no such function: INSTR"

Question by Compi | 2017-08-19 at 11:41

I am getting a strange error when using the function INSTR() in SQLite. When executing a query like SELECT id FROM tab WHERE INSTR(txt, 'abc') > 0 for example, I get the error message "no such function: instr".

According to the SQLite documentation, SQLite has the function INSTR() and as far as I can estimate, also the syntax of my query should be correct. So, what could be the reason that this is not working? I really do not know what I am doing wrong here.

ReplyPositiveNegative
Avatar
0Best Answer0 Votes

The INSTR-function was introduced with SQLite version 3.7.15. Probably you are using an older version of SQLite in which the function has not been implemented yet. This is also how to explain this error: SQLite is not knowing this function yet.

For finding out your SQLite version, you can use the following query which will display it:

SELECT sqlite_version();

Now you can do two things. Either you are updating your SQLite to a higher version (for example with getting the newest DLL or your required other library from the website of SQLite) or you're using another function that is already available in your SQLite version. For example, instead of INSTR, you can also use LIKE:

SELECT id FROM tab WHERE txt LIKE '%abc%';

This statement would correspond to your query "SELECT id FROM tab WHERE INSTR(txt, 'abc') > 0". However, please consider that LIKE is working independent from uppercase and lowercase writing (case insensitive) while INSTR is caring about the writing (case sensitive). So, your "abc" will not match "Abc" with INSTR, while LIKE is matching it.
2017-08-19 at 16:16

ReplyPositive Negative
Reply

Related Topics

"G" or "E" sign on my mobile

Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.