Execute query : Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints

I am connecting to mysql and when a execute the activity Execute Query I have the net error:

Execute query : Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

It’s a query from one table without joins. I have 4 tables and I only can do a select * from one table, the others return the above error.

I would understand this error if I had inserting data but not executing a query.

Thanks,

Hi jalbalat,

Does your table have any default value?
Default value can cause that error.
in my case, some columns had 0 and 0000-00-00 for default values and those zero values caused same error.

I suggest you to avoid using zero for default value.
If you can’t, then use IF statement to avoid print out zero default value.
It is bit of hassle but may solve your problem.

Sam

1 Like

I had similar issue with executing query over ODBC to SQL Server 2016.
Error was:
Execute Query: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

The reason - MS SQL Table field was defined as nvarchar(max). Changing the type to nvarchar(4000) fixed the issue.

I had the same problem and i see that the problem was the ODBC driver, when connect with the same ODBC in the MySQL Client, that all the fields in all the rows was “NULL”
When i changed “MySQL ODBC 8.0 Unicode Driver” by “MySQL ODBC 8.0 ANSI Driver” the query starts to work

1 Like

Thanks, changing to ANSI driver fixed it for me a year later!

@jalbalat, if this worked for you you should mark it as solved!

@lbell92 How did you set up the driver in UiPath Studio?
Thanks!

Hey @PeCour,

You need to download and install the MySQL ODBC ANSI driver to your system and configure it under the ODBC Data Source Administrator tool in Windows, then you can use it in your Connect to Database activity in UiPath Studio.

These 2 posts should help explain.

1 Like

Hey @lbell92,
thank you for your help!