SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_tt_policies_variable_umr_value]
	@policies_situations_table type_table_id readonly,
	@variable_code ais_code_short

as
	set nocount on;
	 
	select 	pols_policy_situation_id = pst.id, 
			umr_value = risv_umr_value 
	from ris_risks_situations rrs 	
		inner join @policies_situations_table pst on rrs.riss_policy_situation_id = pst.id
		inner join ris_variables rv on rv.risv_risk_situation_id = rrs.riss_risk_situation_id
		inner join pr_products_variables ppv on ppv.prdv_variable_id = rv.risv_variable_id
	where prdv_variable_code = @variable_code
GO
