SCRIPT SELECTIONNE :
QC16744 - Annulation versement DD cree des doublons.sql
-- QC16744
-- Lors de l'annulation d'un versement DD une nouvelle ligne est generee en doublon
-- 2 variables sont a modifier :
-- Numero de compte DD et code hotel (sans le H)
Set nocount on
Declare @Error int
Declare @NbRec int
Declare @DD_Account int = CPT-DD, -- Modifier ici le compte DD client (attention a la virgule)
@Hotel_ID int = XXXX -- Modifier ici le code hotel (sans le H)
select * from AR_PAYMENT where ARAC_ID = @DD_Account
and ARPA_AMOUNT='0.00' and ARPA_AMOUNT_FOREIGN ='0.00'
and HOTE_ID = @Hotel_ID
select * from AR_PAYMENT_FOLIO
where ARPA_ID in (
select ARPA_ID from AR_PAYMENT
where ARAC_ID = @DD_Account
and ARPA_AMOUNT='0.00' and ARPA_AMOUNT_FOREIGN ='0.00'
and HOTE_ID = @Hotel_ID )
update AR_PAYMENT_FOLIO set ARAC_ID = -ARAC_ID , HOTE_ID = -HOTE_ID
where ARPA_ID in (
select ARPA_ID from AR_PAYMENT
where ARAC_ID = @DD_Account
and ARPA_AMOUNT='0.00' and ARPA_AMOUNT_FOREIGN ='0.00'
and HOTE_ID = @Hotel_ID )
update AR_PAYMENT
set ARAC_ID = - ARAC_ID , HOTE_ID = - HOTE_ID
where ARAC_ID = @DD_Account
and ARPA_AMOUNT='0.00' and ARPA_AMOUNT_FOREIGN ='0.00'
and HOTE_ID = @Hotel_ID
set @NbRec = @@rowcount
Set @Error = @@error If @Error <> 0 Goto Err
Print 'Insert done : ' + LTrim(Str(@NbRec)) + ' rows affected'
Err:
If @Error<> 0
Begin
Raiserror ('Error the treatment" - ERROR NUMBER : %d ', 16, -1,'', ' ', @Error)
End
© Untitled. All rights reserved. | Support Technique Fols N2