Hmm... with some more investigation it seems that the expected value is "null" not null! This would explain the error, but why would a null get stored as a character string in SQLite?
The code that I use to populate the sqlite table is this:
B4X:
Dim dispositionPK As String
If chkDelivered.Checked = False Then
dispositionPK = dispositionMap.Get(spnDisposition.SelectedItem)
Else
dispositionPK = Null
End If
m.Put("del_dspfk", dispositionPK)
DBUtils.InsertMaps(SQLLite, "DeliveryHistory", ListOfMaps)
How can I add a null value in? Should I change the code to this instead?
B4X:
Dim dispositionPK As String
If chkDelivered.Checked = False Then
dispositionPK = dispositionMap.Get(spnDisposition.SelectedItem)
m.Put("del_dspfk", dispositionPK)
End If
DBUtils.InsertMaps(SQLLite, "DeliveryHistory", ListOfMaps)
I suspect the problem is in DBUtils not dealing with nulls correctly. Try building your own string and use ExecNonQuery and use the SQLite NULL keyword.
B4X:
Dim sInsertSring As String
sInsertSring = 'INSERT INTO DeliveryHistory (del_dspfk) VALUES (NULL)'
Thanks, changing my code where I just don't issue a Put on the map for this key works.
I suspect doing this would also work:
B4X:
m.Put("del_dspfk", Null)
As I have code similar to that elsewhere, but maybe there is a problem with DBUtils converting a variable with a null value, or maybe there's something wrong with my code assigning the Null value to the variable.