Since JSQL Resultsets are forward only I would like to copy the data rather than make another round trip to the server
I tried some of the CopyObject routines suggested here but was unable to make them work with a ResultSet object.
Is there a simple way to save the data for each row as an object and access like I do the ResultSet or do I have to iterate through each of the fields and save them to a Type?
I'm not sure how your database is structured or what your use case is but you might be able to work with a List of Lists or a List of Maps.
B4X:
'List of Lists, each row is a List, you will access each element by its index
Dim r As ResultSet = ....
Dim Results As List
Results.Initialize
Do While r.NextRow
Dim row As List
row.Initialize
For j = 0 To r.ColumnCount-1
row.Add(r.GetString2(j))
Next
Results.Add(row)
Loop
r.Close
B4X:
'List of Maps, each row is a Map, you will access elements by their column name
Dim r As ResultSet = ...
Dim Results As List
Results.Initialize
Do While r.NextRow
Dim row As Map
row.Initialize
For j = 0 To r.ColumnCount-1
row.Put(r.GetColumnName(j), r.GetString2(j))
Next
Results.Add(row)
Loop
r.Close
I'm not sure how your database is structured or what your use case is but you might be able to work with a List of Lists or a List of Maps.
B4X:
'List of Lists, each row is a List, you will access each element by its index
Dim r As ResultSet = ....
Dim Results As List
Results.Initialize
Do While r.NextRow
Dim row As List
row.Initialize
For j = 0 To r.ColumnCount-1
row.Add(r.GetString2(j))
Next
Results.Add(row)
Loop
r.Close
B4X:
'List of Maps, each row is a Map, you will access elements by their column name
Dim r As ResultSet = ...
Dim Results As List
Results.Initialize
Do While r.NextRow
Dim row As Map
row.Initialize
For j = 0 To r.ColumnCount-1
row.Put(r.GetColumnName(j), r.GetString2(j))
Next
Results.Add(row)
Loop
r.Close
Thought of that and that is what I am currently working on doing in the absence of a better solution. Just seems like their should be a way to get the row as an object without having to iterate through all of the fields.