Previous Topic: Add CREATE Entity ActionNext Topic: Add READ Entity Action


Add Exception Logic to a CREATE Entity Action

Exception logic defines the actions to take if an exception to an entity action occurs. You can add the following exception conditions to a CREATE action:

The WHEN already exists condition lets you define the actions to be taken if the entity occurrence already exists. The WHEN successful condition lets you define the actions to be taken when the entity occurrence is successfully created. The WHEN permitted value violation condition lets you manage the error that occurs when the application attempts to write a column to the database with a value other than a permitted value. If the exception condition is not included and a permitted value error occurs, the transaction is terminated. CA Gen-generated applications cannot write data that violates permitted value constraints to the database.

The exception logic is added automatically to the CREATE entity action group. If actions are to be taken when an exception occurs, you must add the exception action to the entity action group. If you do not add logic for the WHEN permitted value violation condition, a runtime error is issued when the condition occurs.

In the following example, the CREATE statement shows exception logic noting that information about entity occurrence (PRODUCT) is already stored.

CREATE received product
SET code TO import product_code
ASSOCIATE WITH processing warehouse WHICH holds IT
WHEN successful
WHEN already exists
WHEN permitted value violation