# How to update history variable which is a longstring type variable

**URL:** <https://forum.flowable.org/t/how-to-update-history-variable-which-is-a-longstring-type-variable/2865>\
**Category:** Uncategorized\
**Created:** [November 7, 2018, 9:02am UTC](https://forum.flowable.org/t/how-to-update-history-variable-which-is-a-longstring-type-variable/2865 "2018-11-07T09:02:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![clinan](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@clinan](https://forum.flowable.org/u/clinan)\
**Post date:** [November 7, 2018, 9:02am UTC](https://forum.flowable.org/t/how-to-update-history-variable-which-is-a-longstring-type-variable/2865/1 "2018-11-07T09:02:35Z")

</div>

How to update history variable which is a longstring type variable。  
historicVariableInstanceEntityManager.update(historicVariableInstanceByVariableInstanceId, true);  
It will cause this error :Data too long for column ‘TEXT\_’ at row 1  
Can you give me a solution. Thank you!

---

<div class="post-metadata">

**Author:** ![clinan](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@clinan](https://forum.flowable.org/u/clinan)\
**Post date:** [November 8, 2018, 7:13pm UTC](https://forum.flowable.org/t/how-to-update-history-variable-which-is-a-longstring-type-variable/2865/2 "2018-11-08T19:13:27Z")

</div>

```
import org.flowable.common.engine.impl.interceptor.Command;

```

import org.flowable.common.engine.impl.interceptor.CommandContext;  
import org.flowable.variable.api.history.HistoricVariableInstance;  
import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity;  
import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntityManager;  
import org.flowable.variable.service.impl.util.CommandContextUtil;

public class SetHistoryVariablesCmd implements Command, Serializable {

```
private static final long serialVersionUID = 1L;
private HistoricVariableInstance historicVariableInstance;
private String jsonStr;

public SetHistoryVariablesCmd(HistoricVariableInstance historicVariableInstance, String jsonStr) {
    this.historicVariableInstance = historicVariableInstance;
    this.jsonStr = jsonStr;
}

@Override
public Object execute(CommandContext commandContext) {
    HistoricVariableInstanceEntityManager historicVariableInstanceEntityManager
        = CommandContextUtil.getHistoricVariableInstanceEntityManager(commandContext);
    HistoricVariableInstanceEntity historicVariableInstanceByVariableInstanceId = historicVariableInstanceEntityManager
        .findHistoricVariableInstanceByVariableInstanceId(historicVariableInstance.getId());
    historicVariableInstanceByVariableInstanceId.setLastUpdatedTime(new Date());
    if (historicVariableInstanceByVariableInstanceId.getByteArrayRef() != null) {
        // the method set json data into db, but the data charset is error
        historicVariableInstanceByVariableInstanceId.setBytes(jsonStr.getBytes());
    } else {
        historicVariableInstanceByVariableInstanceId.getVariableType();
        historicVariableInstanceByVariableInstanceId.setTextValue(jsonStr);
    }
    historicVariableInstanceEntityManager.update(historicVariableInstanceByVariableInstanceId, false);
    return true;
}

```

}
