Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

363
Vistas
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 Respuestas
Responde la pregunta

0

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

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda