Delete detail issue

Hi,

I have a master - detail relationship that I created using Data Modeler.

The detail table has other fk also to other tables except master.

When I delete a detail row at the database does not delete the whole record but only make field master field fk null.

Where is the catch here?

Regards,
Nikos
Hi Nikos,
You should add TCascadeType.RemoveOrphan to the detail cascade:

Hi Wagner,

is there a way to select that behavior from Data Modeler?

Yes: http://www.tmssoftware.biz/business/dmodeler/doc/web/adding-orderby-attribute-to-ma_2.html

Hi Wagner,

thanks a lot for the directions.

Just a sily note, but will be useful if you correct the documentation CascadeTypeRemoveOrphan must be [TCascadeType.RemoveOrphan]

example:
procedure OnManyValuedAssociationGenerated(Args: TManyValuedAssociationGeneratedArgs);
begin                  
  case Args.CodeType.Name of
    'TEmployees':
       case Args.Field.Name of 
         'FEmployeesList':
             TCodeSnippetExpression(Args.AssociationAttr.Arguments[1].Value).Value := '[TCascadeType.SaveUpdate, TCascadeType.Merge, TCascadeType.RemoveOrphan]';
       end;
  end;             
end;

Thanks for the feedback, we will fix it. But it should be "CascadeTypeAllRemoveOrphan", not "[TCascadeType.RemoveOrphan]".

Example:


procedure OnManyValuedAssociationGenerated(Args: TManyValuedAssociationGeneratedArgs);
begin                   
  case Args.CodeType.Name of
    'TEmployees': 
       case Args.Field.Name of  
         'FEmployeesList': 
             TCodeSnippetExpression(Args.AssociationAttr.Arguments[1].Value).Value := 'CascadeTypeAllRemoveOrphan';
       end;
  end;              
end;