How to check a value in a SQLite column is NULL or not with C API?

9.4k views Asked by At

I'm using SQLite with C API. On C API, I can check the result value of a column with sqlite3_column_* functions. the problem is there is no function for the case of the value is NULL. Of course, I can check the value with sqlite3_column_bytes function, but it can cause conversion, and I want to avoid conversion at all.

How can I check the value at a column of a row is NULL or not?

1

There are 1 answers

0
Joachim Isaksson On BEST ANSWER

From what I can remember (and tell from the documentation), the correct way to do it is to use sqlite3_column_type() to check for SQLITE_NULL.

Just be sure to do it before doing anything that may cause conversion of the column.