I have an old B4A big project with lots of loops using Cursors from SQLite db.
All loops are rather complex, big, like:
B4X:
Dim c As Cursor = Starter.SQL.ExecQuery("SELECT * FROM .....")
If c.RowCount = 0 Then 'sometimes such condition is the must
Return
End If
For i = 0 To c.RowCount - 1
c.Position = i
Dim var001 As String = c.GetString("var001")
.....
'lots of codes with many VARxxx
Next
'sometimes some extra code here after the loop, so pre-checking RowCount sometimes is strongly required
Now suddently i have to make porting of that old project to B4J.
How to migrate to ResultSet simpler and errorless ?
Dim c As ResultSet = Starter.SQL.ExecQuery("SELECT * FROM .....")
Do While c.NextRow
Dim var001 As String = c.GetString("var001")
.....
'lots of codes with many VARxxx
Loop
Dim c As ResultSet = Starter.SQL.ExecQuery("SELECT * FROM .....")
Dim RowCount As Int = 0
Do While c.NextRow
Dim var001 As String = c.GetString("var001")
.....
'lots of codes with many VARxxx
RowCount = RowCount +1
Loop
If RowCount = 0 Then Return
'sometimes some extra code here after the loop, so pre-checking RowCount sometimes is strongly required
Dim strValue01 As String
Dim intValue02 As Int
Dim dblValue03 As Double
Dim RowCount As Int
Dim Query As String = $"SELECT
var001,
var002,
var003
FROM Table01"$
Dim RS1 As ResultSet = Starter.SQL.ExecQuery(Query)
Do While RS1.NextRow
strValue01 = RS1.GetString("var001")
intValue02 = RS1.GetInt("var002")
dblValue03 = RS1.GetDouble("var003")
RowCount = RowCount + 1
Loop
RS1.Close
If RowCount = 0 Then Return