SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE procedure [dbo].[p_sys_fs_AddCplSourceControlledObjects]
as 

if exists(select 1 from nm_reference_database_objects)
begin
	insert into nm_reference_database_objects(nrdo_SchemaName,nrdo_ObjectName,nrdo_ObjectType,nrdo_ObjectTypeDescription)
	select	nrdo_SchemaName,nrdo_ObjectName,nrdo_ObjectType,nrdo_ObjectTypeDescription 
	from (
				select 'dbo' as nrdo_SchemaName,'act_cpl' as nrdo_ObjectName,'U' as nrdo_ObjectType,'CPL Acteurs' as nrdo_ObjectTypeDescription
	union all	select 'dbo' as nrdo_SchemaName,'ris_cpl' as nrdo_ObjectName,'U' as nrdo_ObjectType,'CPL Risques' as nrdo_ObjectTypeDescription
	union all	select 'dbo' as nrdo_SchemaName,'pol_cpl' as nrdo_ObjectName,'U' as nrdo_ObjectType,'CPL Contrats' as nrdo_ObjectTypeDescription
	union all	select 'dbo' as nrdo_SchemaName,'claim_cpl' as nrdo_ObjectName,'U' as nrdo_ObjectType,'CPL Sinistres' as nrdo_ObjectTypeDescription
	union all	select 'dbo' as nrdo_SchemaName,'claim_actors_cpl' as nrdo_ObjectName,'U' as nrdo_ObjectType,'CPL Acteurs sinistres' as nrdo_ObjectTypeDescription

	union all	select 'dbo' as nrdo_SchemaName,'vw__obj_objects_select' as nrdo_ObjectName,'V' as nrdo_ObjectType,'View objets select' as nrdo_ObjectTypeDescription
	union all	select 'dbo' as nrdo_SchemaName,'vw__obj_objects_insert' as nrdo_ObjectName,'V' as nrdo_ObjectType,'View objets insert' as nrdo_ObjectTypeDescription
	union all	select 'dbo' as nrdo_SchemaName,'vw_act_types' as nrdo_ObjectName,'V' as nrdo_ObjectType,'Acte types' as nrdo_ObjectTypeDescription

		) as t
	where not exists(select 1 from nm_reference_database_objects n where n.nrdo_SchemaName = t.nrdo_SchemaName and n.nrdo_ObjectName = t.nrdo_ObjectName and n.nrdo_ObjectType = t.nrdo_ObjectType)
end
GO
