188.A business requires that every parent record must have a child record. A developer writes an Apex method with two DML statements to insert a parent record and a child record. A validation rule blocks child records from being created. The method uses a try/catch block to handle the DML exception.
What should the developer do to ensure the parent always has a child record?
一个业务要求每个父记录都必须有一个子记录。开发人员编写了一个Apex方法,其中包含两个DML语句,用于插入父记录和子记录。
验证规则会阻止创建子记录。该方法使用 try/catch 块来处理 DML异常。
开发人员应该怎么做才能确保父记录始终有一个子记录?