MATLAB: Is it possible to extract data from a SQLite database with null values

databasenull valuessqlite

Hi there – I am new to databases and am running into some trouble with SQLite.
I have a SQLite database where I can retrieve data from variables with no null values successfully, but variables with empty entries throw an error in SqlDbConnector/fetchRows. I have dbprefs set with NullStringRead and NullNumberRead to 'null'; however, I get the error:
Error using matlab.depfun.internal.database.SqlDbConnector/fetchRows Unexpected NULL; (zero-based) column index: 0; details: initVecVarVecFromSqldbTypes().
% Isolate the walk of patient "McKay" 's first walk over the gaitmat. It
% should have two passes.
ID_i = num2str(ID{1})
% id is retrieved correctly
id = fetch(db, ['SELECT id FROM FootFall WHERE Gait_id = ' ID_i])
% variables with blank rows are retrieved incorrectly
PassNo = fetch(db, ['SELECT PassNo FROM FootFall WHERE Gait_ID = ' ID_i])
Blob1 = fetch(db, ['SELECT Blob1 FROM FootFall WHERE Gait_id = ' ID_i])
Is this a limitation in SQLite, or should I have dbprefs set differently? Any help appreciated.

Best Answer

This could be because of a bug in the SQLite JDBC driver:
MATLAB uses the wasNull() method to determine whether a null value was returned (such that we can replace it with the 'NullStringRead' value). wasNull() unexpectedly throws an exception here.