SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create procedure [dbo].[p_policy_renewal_principal_variables]
	@policies_situations type_table_id READONLY,
	@risks_situations type_table_id READONLY
as

-- pentru terme-urile principale selectam doar codurile variabilelor ca sa stim ce sa calculam, nu ne putem baza pe formula pentru ca e posivbil sa fi adaugat variabile optionale

set nocount on
	
--selectie variabile contracte
select v.polv_policy_situation_id, v.polv_variable_id, p.prdv_variable_code, p.prdv_variable_date_setup
from pol_variables v
	inner join @policies_situations on polv_policy_situation_id = id
	inner join pr_products_variables p on v.polv_variable_id = p.prdv_variable_id

-- taxele contract nu le selectam, o sa se adauge/calculeze in cod
		
-- selectie variabile riscuri
select rv.risv_risk_situation_id, rv.risv_variable_id, p.prdv_variable_code, p.prdv_variable_date_setup
from ris_variables rv
	inner join @risks_situations on id = risv_risk_situation_id
	inner join pr_products_variables p on rv.risv_variable_id = p.prdv_variable_id
	 
-- taxele risk nu le selectam, o sa se adauge/calculeze in cod



	

	
		
	








GO
