SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_acc_transaction_delete]
	@transaction_id int
as 

	set nocount on;


	-- suppression de la transaction en cours

	declare @type ais_code_short


	select	@type = upper(isnull(atrn_type_code, ''))
	from	acc_transactions
	where	atrn_transaction_id = @transaction_id


	if @type = 'ACO'
	begin
		exec p_acc_transaction_delete_aco @transaction_id
	end
	else if @type in ('EC', 'RMB', 'AEC')
	begin
		exec p_acc_transaction_delete_ec_aec_rmb @transaction_id
	end	
	else if @type = 'PEC'
	begin
		exec p_acc_transaction_delete_pec @transaction_id
	end
	else if @type IN ('CLAIM_P', 'CLAIM_R', 'CLAIM_X')
	begin
		exec p_acc_transaction_delete_claim_prx @transaction_id, @type
	end
	else	begin 
		raiserror('Unknown transaction type ', 16,1)
		return
	end


GO
