SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_pr_products_introducers]
	@product_code ais_code_short,
	@branch_id int,
	@introducer_id as varchar(15),
	@show_freeze bit
	
AS

set nocount on;

	declare @id int

	if @introducer_id = '%' 
		set @id = 0
	else
		set @id = convert(int, @introducer_id)

select	i.*, v.*
from	vw_act_introducers v
		inner join pr_products_introducers i on act_actor_id = prdint_introducer_id
where	prdint_product_code = @product_code	
and		prdint_branch_id = @branch_id
and		(@id = 0 or act_actor_id = @id)
AND		(
		@show_freeze <> 0
		OR 
		act_freeze = 0
		)
ORDER BY v.act_internal_reference, i.prdint_retro_code

GO
