Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

359
Views
Equivalent of sqlite3_column_int to get possible NULL values

in my app, I am using a SQLite database to store some data. One of the integer fields is optional, so it is defined like so:

I have the following CREATE statement:

CREATE TABLE IF NOT EXISTS Test (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp FLOAT NOT NULL, testProperty INT);

I can get the float property using sqlite3_column_double. For the int column I could use 'sqlite3_column_int' but this always returns a value (0) even if the row does not contain a value.

How can I check if the row actually has a value for this property?

I have the following code to get all rows:

var statement: OpaquePointer? = nil
let sql = "SELECT * FROM Test;"
   
sqlite3_prepare_v2(self.connection, sql, -1, &statement, nil)
    
while sqlite3_step(statement) == SQLITE_ROW
{
  let testProperty = sqlite3_column_int(statement, 2) // always returns 0
}
    
sqlite3_finalize(statement)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use sqlite3_column_type() to check if it is SQLITE_INTEGER or SQLITE_NULL .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!