insert into tbl_org_attributelinks ( mstr_attrTypeId, mstr_attrId, child_attrTypeId, child_attrId, linkRole ) select 34, , 95, , '#_linkRole#' where not exists ( select * from tbl_org_attributelinks where mstr_attrTypeId = 34 and mstr_attrId = and child_attrTypeId = 95 and child_attrId = and linkrole = '#_linkRole#' ) delete from tbl_org_attributelinks where mstr_attrTypeId = 34 and mstr_attrId = and child_attrTypeId = 95 and child_attrId = and linkrole <> '#_linkRole#'