Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 954
eonil Avatar asked Jan 22 '12 13:01

eonil


1 Answers

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.

like image 132
Joachim Isaksson Avatar answered Oct 23 '22 16:10

Joachim Isaksson