docs: public synchronized void set(FieldTable table) throws DBException
      {
          BaseBuffer bufferNew = (BaseBuffer)table.getDataSource(); // same as .getHandle(Constants.DATA_SOURCE_HANDLE);
          if (table.getRecord().getEditMode() == Constants.EDIT_IN_PROGRESS)
          {
              PKeyArea vKeyArea = this.getPKeyArea(Constants.MAIN_KEY_AREA);
              KeyAreaInfo primaryKeyArea = table.getRecord().getKeyArea(Constants.MAIN_KEY_AREA);
              primaryKeyArea.reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);     // Move these keys back to the record
              BaseBuffer bufferOld = vKeyArea.doSeek("==", table, primaryKeyArea);    // Get the old record back
              if ((bufferOld == null) || (bufferOld.getPhysicalData() == null))
                  throw new DBException(Constants.INVALID_RECORD);    // This record had been freed (deleted)
  
              for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea < table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA; iKeyArea++)
              {
                  try   {
                      vKeyArea = this.getPKeyArea(iKeyArea);
                      KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyArea);
                      keyArea.reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);        // Move these keys back to the record
                      if (keyArea.getUniqueKeyCode() != Constants.UNIQUE)   // The main key is part of the comparison
                          primaryKeyArea.reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);     // Move these keys back to the record
                      vKeyArea.doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
                      bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
                      vKeyArea.doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
                  } catch (DBException e)   {
                      if (e.getErrorCode() == Constants.DUPLICATE_KEY)
                      {
                          bufferOld.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
                          this.getPKeyArea(iKeyArea).doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
                          iKeyArea--;     // Duplicate key, back out all keys added so far!!!
                          while (iKeyArea >= Constants.MAIN_KEY_AREA)
                          {
                              vKeyArea = this.getPKeyArea(iKeyArea);
                              KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyArea);
                              bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
                              vKeyArea.doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
                              keyArea.reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);        // Move these keys back to the record
                              if (keyArea.getUniqueKeyCode() != Constants.UNIQUE)   // The main key is part of the comparison
                                  primaryKeyArea.reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);     // Move these keys back to the record
                              vKeyArea.doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
                              iKeyArea--;
                          }
                      }
                      throw e;
                  }
              }
              if (bufferNew != bufferOld)
                  bufferOld.free();   // Get rid of the old one
              bufferOld = null;
              // Restore the record before returing (key.doWrite probably changed it).
              bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
          }
          else
              throw new DBException(Constants.INVALID_RECORD);
      }