alter table MGOST_SERVICIOS
add constraint FK_MGOST_SERVICIOS_1
foreign key (ORDEN_SERVICIO_ID)
references MGOST_ORDENES_SERVICIOS(ORDEN_SERVICIO_ID);



SET TERM ^ ;

CREATE trigger mgost_ordenes_servicios_bd0 for mgost_ordenes_servicios
active before delete position 0
AS
begin
 /* Eliminar la liga de este docto con el de otro sistema. */
    DELETE FROM MGOST_SERVICIOS
    WHERE ORDEN_SERVICIO_ID = OLD.ORDEN_SERVICIO_ID;

    DELETE FROM MGOST_OC
    WHERE ORDEN_SERVICIO_ID = OLD.ORDEN_SERVICIO_ID;
end
^

SET TERM ; ^


update RDB$RELATION_FIELDS set
RDB$NULL_FLAG = 1
where (RDB$FIELD_NAME = 'NOMBRE') and
(RDB$RELATION_NAME = 'MGOST_MECANICOS')
;



