Child pages
  • Errors & Warnings

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleUpdate/insert failed, unexpected nr of records affected: expected 1, actual 0

This error indicates that an update or delete of a record failed.

When Servoy performs an update or delete is performed on a record, Servoy it checks whether the database reports back that the record was actually updated or deleted. If the database reports that the update or delete did not take place, the Update/insert failed, unexpected nr of records affected: expected 1, actual 0 error is reported.

The database can report that the update or delete failed when based on the SQL executed on the database no record was found to update or delete. There could be different reasons for the database not being able to locate the record to update or delete, some of which are explained below.

One scenario that may cause result in this error is when records are created that do not match the active filters: when a record is deleted or updated in the database the active filter conditions (FoundSet filters and table filters) are added to the generated sql. If the conditions are not met, the update will not happen and Servoy throws this exception. For example, a table filter 'tenant_id = 4' is active and a new customer record is created with null value for the tenant_id. This record can be saved in the database, but a consecutive update or delete will fail (update customers set name = ? where id = ? and tenant_id = 4).

Another scenario that may cause this error to be raised is when data is the record modified/deleted outside Servoy and Servoy is not notified. For example, an orders record is deleted from outside of Servoy while it is loaded in a Servoy Client and that Servoy Client then attempt to delete it. That delete fails with the above error because the database reports that delete from Servoy did not occur, because the record didn't exist.

By default the Servoy Application Server will raise this exception when such scenario occurs. It is possible to suppress these errors by setting the server property servoy.server.throwErrorOnUnexpectedUpdateCount to false. However, this should be used with care and only as a temporary solution until the underlying problem has been discovered and fixed.

...