SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create procedure [dbo].[p_policy_last_situation_incomplete]
    @policies_table type_table_id readonly

as
    set nocount on;

    select pols_policy_id, pols_policy_situation_id
    from pol_policies pp
	   inner join @policies_table pt on pt.id = pp.pol_policy_id
	   inner join pol_policies_situations pps on pp.pol_last_policy_situation_id = pps.pols_policy_situation_id
    where pps.pols_incomplete = 1


    
GO
