Conflict error when list of fields is used in select during update transaction

If you use this code, you will get an error on the line 29. The error message is following:

Cannot edit a record in Table1 (Table1).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

  1: static void updateTable1(Args _args)
 2: {
 3:    Table1 tbl;
 4:    ;
 5:
 6:    ttsbegin;
 7:    select firstonly forupdate tbl;
 8:
 9:    if (tbl.RecId)
10:    {
11:        tbl.InfoText = "Reset";
12:        tbl.update();
13:    }
14:    else
15:    {
16:        tbl.InfoText = "Reset";
17:        tbl.IntField = 1;
18:        tbl.insert();
19:    }
20:    ttscommit;
21:
22:    tbl.clear();
23:
24:    select firstonly RecId, InfoText from tbl;
25:
26:    ttsbegin;
27:    tbl.selectForUpdate(true);
28:    tbl.InfoText = "Table1 - field select";
29:    tbl.update();
30:    ttscommit;
31: }

The reason for this is that each time the table is updated the field RecVersion is updated with a random number that is saved by kernel. That why when you try to update the record, kernel cannot update record partly, what results in update conflict.

There are two ways to avoid this issue:

1. Add RecVersion field into the selection

 24:    select firstonly RecId, InfoText, RecVersion from tbl;

2. Use selectforupdate keyword

 24:    select firstonly forupdate RecId, InfoText from tbl;

Martin F