-- MISE A JOUR AVENANT

SELECT * FROM police  WHERE libellePolice LIKE '%com%'

SELECT * FROM avenant  WHERE idPolice= 233




SELECT * FROM beneficiaire
WHERE 
idPolice='233' AND idAvenant=636 
AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)

-- 0 -- mise a jour date d'entre
UPDATE beneficiaire
SET idAvenant=636 
WHERE idPolice='233' AND idAvenant=636 
AND dateEntree='2022-05-18'   --  AND codeLienParente='A'

UPDATE adherent
SET dateEffet='2022-04-01' ,dateEntree='2022-04-01'
WHERE idPolice='233' AND idAvenant=636 
AND dateEntree='2022-05-06'

UPDATE beneficiaireprime
SET dateEffetBeneficiaire='2022-04-01' ,dateEffetAdherent='2022-04-01' ,dateEffet='2022-04-01'
WHERE idPolice='233' AND idAvenant=636 
AND dateEffet='2022-05-06'


-- 1--
UPDATE beneficiaire
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)



-- 2--
UPDATE adherent
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 AND dateCre='2022-05-08'
AND id IN (9407,9408)


-- 3---
UPDATE beneficiaireprime
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 -- AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)



-- 4 --
UPDATE hbeneficiaireprime
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 -- AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)



-- 5 --
UPDATE adherentsupprime
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 -- AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)


-- 6 --
UPDATE beneficiairesupprime
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 -- AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)


-- 7 --
UPDATE beneficiaireavenant
SET idAvenant=738 
WHERE idPolice='233' AND idAvenant=636 -- AND dateCre='2022-05-08'
AND idAdherent IN (9407,9408)



-- 8 -- SUPRESSION DE L'AVENANT
DELETE FROM avenant  
WHERE idPolice=223 AND id!=636


SELECT * FROM avenant  
WHERE idPolice=223 AND id!=636