No such function: iif in SQLITE

Viewed 5901

community.

I have a quite typical task in SQLITE.

In case of X return Y, else Z.

For such purpose I was using CASE statement

"CASE WHEN X THEN Y ELSE Z END".

However, I found IIF function in official documentations

https://sqlite.org/lang_corefunc.html#iif

iif(X,Y,Z) The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwise. The iif(X,Y,Z) function is logically equivalent to and generates the same bytecode as the CASE expression "CASE WHEN X THEN Y ELSE Z END".

But when trying to run such function, I get an error.

Execution finished with errors. Result: no such function: iif

What is the problem with this function? According to official documentation, such function should exist.

1 Answers

Thanks @paddy and his link for this post IF() statement alternative in SQLite

The problem came from SQLite version, which should be 3.32 or higher. I've been using SQLite Browser, and sqlite version was 3.25. I updated Sqlite Browser and was able to use IIF function.

Related