SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_ext_policy_replace_create_lot]
	@source_product_code ais_code_short,
	@new_product_code ais_code_short,
	@lot_id INT OUT,
	@error_code ais_code_long OUT
AS
	SET NOCOUNT ON;

	EXEC p_table_next_identity_value @table_name = 'policies_replaced_lots'
									,@next_identity_value = @lot_id OUT
									,@error_code = @error_code OUT

	IF ISNULL(@error_code,'') = ''
	BEGIN
		INSERT INTO policies_replaced_lots (	prl_lot_id,		prl_start_date,		prl_source_product_code,	prl_new_product_code)
		VALUES (								@lot_id,		GETDATE(),			@source_product_code,		@new_product_code);
	END
GO
