Just experimenting with the B4XTable.
I added some extra options to search column values along these lines:
This works all fine, but so far been unable to search for "empty" column values.
I understand that B4XTable doesn't handle SQL Null values (but had some tries with that as well), but even the SQL length function I have been unable to make work
to search for these values.
Any suggestions how this should be done?
I am trying to avoid searching the actual customlistview labels, so I would like to do this with SQL on the memory table.
RBS
I added some extra options to search column values along these lines:
B4X:
For Each col As B4XTableColumn In VisibleColumns
If col.Searchable Then
For n = 0 To arrCheckConditions(c) - 1
strFind = arrConditions(c, n).strSearchText
If args.Size = 0 Then
sb.Append(" WHERE ")
Else
If arrConditions(c, n).bSQL_OR Then
'this used to be all OR
sb.Append(" OR ")
Else
sb.Append(" AND ")
End If
End If
If col.ColumnType = COLUMN_TYPE_INTEGER Or col.ColumnType = COLUMN_TYPE_DOUBLE Then
If arrConditions(c, n).strOperator.Length = 0 Then
sb.Append(col.SQLID).Append(" = ? ")
Else
sb.Append(col.SQLID).Append(" " & arrConditions(c, n).strOperator & " ? ")
End If
args.Add(strFind)
Else
If arrConditions(c,n).bWildCard Then
If arrConditions(c,n).bCaseSensitive Then
sb.Append(col.SQLID).Append(" GlOB ? ")
If arrConditions(c,n).bPrefixSearch Then
args.Add(strFind & "*")
Else
args.Add("*" & strFind & "*")
End If
Else
sb.Append(col.SQLID).Append(" LIKE ? ")
If arrConditions(c,n).bPrefixSearch Then
args.Add(strFind & "%")
Else
args.Add("%" & strFind & "%")
End If
End If
Else
If arrConditions(c, n).bCaseSensitive Then
If arrConditions(c, n).strOperator.Length = 0 Then
sb.Append(col.SQLID).Append(" = ? ")
Else
sb.Append(col.SQLID).Append(" " & arrConditions(c, n).strOperator & " ? ")
End If
args.Add(strFind)
Else
If arrConditions(c, n).strOperator.Length = 0 Then
sb.Append("lower(").Append(col.SQLID).Append(") = ? ")
Else
sb.Append("lower(").Append(col.SQLID).Append(") " & arrConditions(c, n).strOperator & " ? ")
End If
args.Add(strFind.ToLowerCase)
End If
End If
End If
Next
End If
c = c + 1
Next
TotalCount = -1
End If
This works all fine, but so far been unable to search for "empty" column values.
I understand that B4XTable doesn't handle SQL Null values (but had some tries with that as well), but even the SQL length function I have been unable to make work
to search for these values.
Any suggestions how this should be done?
I am trying to avoid searching the actual customlistview labels, so I would like to do this with SQL on the memory table.
RBS