My first DB project with B4A so probably something basic I am doing wrong. The idea is to store a presentation order column in a table, allowing the user to rearrange the order persistently. But I can't seem to get the initial load of this field to take. I did determine you can not submit update queries while a cursor is open, so the update is deferred....
Sub Activity_Create(FirstTime As Boolean) ... Dim DeliveryPath As String = DBUtils.CopyDBFromAssets("Delivery.db" ) Delivery.Initialize(DeliveryPath,"Delivery.db", False ) Dim curRow As Int ... Try ' Note: PresentationOrder initially zero for all records. Dim lst As List lst.Initialize crs = Delivery.ExecQuery("SELECT * FROM OpenOrderHeader ORDER BY ShipToAddress1, OrderNumber") For curRow = 0 To crs.RowCount-1 crs.Position = curRow Dim ordn As Int = crs.GetInt("OrderNumber") Dim mp As Map mp.Initialize mp.Put("OrderNumber",ordn) lst.Add(mp) Next crs.Close For i = 0 To lst.Size-1 DBUtils.UpdateRecord(Delivery,"OpenOrderHeader","PresentationOrder",i,lst.Get(i)) Next Catch Log(LastException.Message) End Try crs = Delivery.ExecQuery("SELECT * FROM OpenOrderHeader ORDER BY PresentationOrder") ' PresentationOrder is zero for all records in this cursor ' expecting sequentially assigned #s from the above update