Android Question DBUtils.InsertMaps

sivakrith

Member
Licensed User
Hello,
Need to insert / update multiple table(s) using DButils.Insertmaps. Will the below procedure work ? Should take care of database transaction too.


B4X:
lm_map1.Initialize
lm_map1.put("field1", ls_field1)
lm_map1.put("field2", ls_field2)
lst1.add(lm_map1)

lm_map2.Initialize
lm_map2.put('field21', ls_field21)
lm_map2.put('field22', ls_field22)
lst2.add(lm_map2)

If Dbutils.insertmaps(sql, "table1", lst1) = True Then
    If Dbutils.Insertmaps(sql, "table2", lst2) = True Then
        // Message success
    End If
End If

How to rollback table1 records, if some db errors occurs while inserting in table2 ?

Happiness Always
BKR Sivaprakash
 
Top