Wish Resultset

Guenter Becker

Active Member
Licensed User
Hello,
I like to publish some whishes to Erel to enhance the functionality of a Resultset. This may help to make life easier when using it.

Values map: Key Resultset Columnname, Value: Columnvalue
InsertRow and UpdateRow may work on the resultset in a similar way as done by DBUtils.

Add property InsertRow(Values as map) to insert a new row at the end of all.
Add property DeleteRow(Position as long).
Add Property UpdateRow(Values as Map, Position as long)
Add Property FindRow(Column as string, Value as object) as long - return position

This properties will help us to synchronize data of resultset and database table without reloading complete resultset after database data changes like INSERT.
 

Lucas Siqueira

Active Member
Licensed User
Longtime User
use class [B4X] DBUtils 2


B4X:
'Inserts the data to the table.
'ListOfMaps - A list with maps as items. Each map represents a record where the map keys are the columns names
'and the maps values are the values.
'Note that you should create a new map for each record (this can be done by calling Dim to redim the map).
'Returns True if the maps were inserted successfully.
Public Sub InsertMaps(SQL As SQL, TableName As String, ListOfMaps As List) As Boolean
...

' updates multiple fields in a record
' in the Fields map the keys are the column names
Public Sub UpdateRecord2(SQL As SQL, TableName As String, Fields As Map, WhereFieldEquals As Map)
...

' deletes a record
Public Sub DeleteRecord(SQL As SQL, TableName As String, WhereFieldEquals As Map)
...


'Executes the given query and creates a Map that you can pass to JSONGenerator and generate JSON text.
'DBTypes - Lists the type of each column in the result set.
'Usage example: (don't forget to add a reference to the JSON library)
'<code>
'Dim gen As JSONGenerator
'gen.Initialize(DBUtils.ExecuteJSON(SQL, "SELECT Id, Birthday FROM Students", Null, _
'    0, Array As String(DBUtils.DB_TEXT, DBUtils.DB_INTEGER)))
'Dim JSONString As String
'JSONString = gen.ToPrettyString(4)
'Log(JSONString)</code>
Public Sub ExecuteJSON (SQL As SQL, Query As String, StringArgs() As String, Limit As Int, DBTypes As List) As Map
...
 

Guenter Becker

Active Member
Licensed User
I'm sorry that is not the first time discussing this object. I often found that people do not undstand why I am looking or whishing this things.
The post from you Lucas is another example to that.

My whish has exactly nothing to do with DBUtils! DBUtils and It's function named by Lucas are working to change data on side of the database!
The existing problem is that if doing so the data in the resultset remains unchanged. There are no functions to insert/add/or delete any record of the resultset except performing an new select. This is no problem if the select retrives only a few records but may take a long time if there is a big load of records And there will be cases where this is needed.
 
Top