SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_pr_families_list_fields]
	@family_code ais_code_short
as

	declare	@policy_scen_code ais_code_short,
		@risk_scen_code ais_code_short

	select	@policy_scen_code = pf_policy_scen_code, 
			@risk_scen_code = pf_risk_scen_code
	from	pr_families
	where	pf_family_code = @family_code



	select	[fld_table_name] = frmuf_table_name, [fld_field_name] = 'pcpl_' + frmuf_field_name
	from	dyn_scenarios_forms sf
			inner join dyn_forms_used_fields f on f.frmuf_form_code = sf.sf_form_code
	where	sf_scen_code = @policy_scen_code
	union
	select	[fld_table_name] = frmuf_table_name, [fld_field_name] = 'rcpl_' + frmuf_field_name
	from	dyn_scenarios_forms sf
			inner join dyn_forms_used_fields f on f.frmuf_form_code = sf.sf_form_code
	where	sf_scen_code = @risk_scen_code

GO
