ios - Using sqlite3_column_text() to fetch interger value -


i have table text, integer, real , other data types.

i wrote generic sql function read results queries using sqlite3_column_text() so:

char *dataaschar = (char *) sqlite3_column_text(compiledstatement, ii);

although should using sqlite3_column_int etc. read numeric values, above code seems work me. number values string later convert int using [*numberasstring* intvalue].

since using generic function read db values, convenient me. but there can go wrong code?

i use sqlite3_column_type each column determine type , use appropriate function. correct in assuming sqlite3_column_text returns column value in text format , not need value text?

the situation can see implementation failing blob data type.

the documentation says:

these routines attempt convert value appropriate. […] following table details conversions applied:

 internal type  requested type  conversion null           text            result null pointer integer        text            ascii rendering of integer float          text            ascii rendering of float blob           text            add 0 terminator if needed 

Comments