Mot-clé abscent

Fermé
Simo59 - 9 juin 2021 à 15:16
 Simo59 - 9 juin 2021 à 15:39
Bonjour,
j'essaye de mettre à jour le champs refclient mais j'ai toujours l'erreur mot-clé abscent !
Quelqu'un a t-il déjà eu ce problème? et a-t-il trouvé une solution svp?

UPDATE tmission
SET tmission.refclient = (
CASE
WHEN TMISSION.refclient ='1' THEN TMISSION.refclient = TMISSION.REFCLIENT ||' - '||TCONTRAT.REFCETEN
ELSE tmission.refclient = TCONTRAT.REFCETEN
END
where TMISSION.CN_IDCONTRAT = TCONTRAT.IDCONTRAT
and TCONTRAT.REFCETEN like 'CAMP%'
and TMISSION.refclient is not null
and LENGTH(TMISSION.REFCLIENT ||' - '||TCONTRAT.REFCETEN) <= 50
)

1 réponse

jee pee Messages postés 39657 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 28 avril 2024 9 238
9 juin 2021 à 15:23
Bonjour,

la ) devrait être derrière END, mais moi je ne mettrais ni ( ni ) autour du CASE
0
jee pee Messages postés 39657 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 28 avril 2024 9 238
9 juin 2021 à 15:28
ou il manque un select avant le CASE si () c'est un sous select
0
J'ai mis la ( après le end mais j'ai toujours la même erreur, j'ai eu le même résultat sans les parenthèses

UPDATE tmission
SET tmission.refclient =
CASE
WHEN TMISSION.refclient is not null THEN TMISSION.refclient = TMISSION.REFCLIENT ||' - '||TCONTRAT.REFCETEN
ELSE tmission.refclient = TCONTRAT.REFCETEN
END
where TMISSION.CN_IDCONTRAT = TCONTRAT.IDCONTRAT
and TCONTRAT.REFCETEN like 'CAMP%'
and LENGTH(TMISSION.REFCLIENT ||' - '||TCONTRAT.REFCETEN) <= 50
0
jee pee Messages postés 39657 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 28 avril 2024 9 238 > Simo59
9 juin 2021 à 15:35
si c 'est un sous select

UPDATE tmission
SET tmission.refclient = (select 
  CASE 
    WHEN TMISSION.refclient is not null  THEN  TMISSION.REFCLIENT ||' - '||TCONTRAT.REFCETEN
    ELSE TCONTRAT.REFCETEN
  END
  from TCONTrAT
  where TMISSION.CN_IDCONTRAT = TCONTRAT.IDCONTRAT
  and TCONTRAT.REFCETEN like 'CAMP%'
  and LENGTH(TMISSION.REFCLIENT ||' - '||TCONTRAT.REFCETEN) <= 50  )


mais les lignes de tmission exclues du where risquent une affectation à null
0
Simo59 > jee pee Messages postés 39657 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 28 avril 2024
9 juin 2021 à 15:39
Merci Jee Pee maintenant je sais ce que je dois faire :)
0