Error "Data truncation: Data too long for column"
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Error "Data truncation: Data too long for column"

The issue arises when the value received from REDCap or OpenClinica exceeds the character limit of the corresponding field created in OpenSpecimen.

For example:
If the field BX_RESULT is defined as a Text Box in REDCap/OpenClinica, the corresponding field in OpenSpecimen is created as VARCHAR2(255). When the value for BX_RESULT exceeds 255 characters, the OpenSpecimen sync fails.

Solution 1: Change field type in REDCap

In REDCap, update the field type from “Text Box” to “Notes (Paragraph text)”, if the field is going to be a descriptive field with more than 255 characters.

Solution 2: Change the column size in OpenSpecimen database

  1. Log in to the database console → Increase the size of the column based on your need. You can find the details of table and column name from os.log.

    1. ALTER TABLE <table_name> MODIFY COLUMN <column_name> VARCHAR(<desired_max_length>);

  2. Alternatively, if the required maximum size is unknown or highly variable, change the column to MEDIUMTEXT:

    1. ALTER TABLE <table_name> MODIFY COLUMN <column_name> MEDIUMTEXT;

  3. Rerun the synchronisation for the record in REDCap or OpenClinica.

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com