Skip to main content
Question

Newly added row cannot be found

  • June 18, 2026
  • 1 reply
  • 22 views

Forum|alt.badge.img

At the customer we are facing the following issue:

We have a table with a primary key (PK), and this field is of course mandatory.

This column is not an identity column, and currently it cannot be made one because we need to remain compatible with the existing system (RPG/iSeries DB2).

Because the field is mandatory, we populate the PK with a number via the DEFAULT, so that it can be sent to the database already filled in. However, it is possible that a second user generates the same number in the DEFAULT, since it is simply calculated as max number + 1.

Duplicate numbers are not allowed, so in the TRIGGER the number is recalculated to ensure it is unique regardless. This uses the same logic as in the DEFAULT.

As a result, when saving, you may receive a different number than what you initially entered. The GUI is then unable to find the inserted row and shows an error message.

How can we solve this without using an identity column?

There is a risk that, for example when adding a sales order, a user believes they are working on their own order, while in fact they are adding order lines to someone else’s order.

1 reply

@JordyBaas Maybe a lot of effort for a small change of it being needed, but maybe this is could be an option.

Make a function that can generate a unique value bases on data that you have. Maybe the inserted PK + Inserted User value.

If the trigger has to change the PK value to a new one, store the unique value you obtain from the function and the relevant “new” PK value into a helper table.

Make the Create screen part of a process flow to have it check for a possible new PK using the Unique value to find it. If it does have one, use the new value for the next steps, like “Go to row” or “Change filter”. Else keep the existing gained values.

To not have the helper table grow unnecessarily, you can also add a cleanup in the flow after you’ve obtained the required data.