Question concernant un UPDATE
Bonjour
J'ai une question bête... pourquoi cette requête fonctionne avec une sous requette :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| UPDATE FAC_DATA
SET FAC_DATA.TX_CA = FAC_DATA.REAL_ACH / FAC_DATA_TOTAL.REAL_ACH
FROM ( SELECT *
FROM FAC_DATA
WHERE PAYS_ID = @pays AND
GROUPE_ID = 1
) AS FAC_DATA_TOTAL
WHERE FAC_DATA.PAYS_ID = FAC_DATA_TOTAL.PAYS_ID AND
FAC_DATA.PHASE_ID = FAC_DATA_TOTAL.PHASE_ID AND
FAC_DATA.TYPEENTITE_ID = FAC_DATA_TOTAL.TYPEENTITE_ID AND
FAC_DATA.PERIODE_ID = FAC_DATA_TOTAL.PERIODE_ID AND
FAC_DATA.ENTITE_ID = FAC_DATA_TOTAL.ENTITE_ID |
mais pas celle là sans la sous requête ?
Code:
1 2 3 4 5 6 7 8 9 10
| UPDATE FAC_DATA
SET FAC_DATA.TX_CA_MOTRIO = FAC_DATA.REAL_ACH / FAC_DATA_TOTAL.REAL_ACH
FROM FAC_DATA AS FAC_DATA_TOTAL
WHERE FAC_DATA.PAYS_ID = FAC_DATA_TOTAL.PAYS_ID AND
FAC_DATA.PHASE_ID = FAC_DATA_TOTAL.PHASE_ID AND
FAC_DATA.TYPEENTITE_ID = FAC_DATA_TOTAL.TYPEENTITE_ID AND
FAC_DATA.PERIODE_ID = FAC_DATA_TOTAL.PERIODE_ID AND
FAC_DATA.ENTITE_ID = FAC_DATA_TOTAL.ENTITE_ID AND
FAC_DATA.PAYS_ID = @pays AND
FAC_DATA_TOTAL.GROUPE_ID = 1 |
Quand je met cette requête dans ma procédure stockée, j'ai ces erreurs qui sortent :
Citation:
Msg 4104, Level 16, State 1, Procedure myProcedure, Line 14
The multi-part identifier "FAC_DATA.PAYS_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure myProcedure, Line 14
The multi-part identifier "FAC_DATA.PHASE_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure myProcedure, Line 14
The multi-part identifier "FAC_DATA.TYPEENTITE_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure myProcedure, Line 14
The multi-part identifier "FAC_DATA.PERIODE_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure myProcedure, Line 14
The multi-part identifier "FAC_DATA.ENTITE_ID" could not be bound.
Msg 4104, Level 16, State 1, Procedure myProcedure, Line 14
The multi-part identifier "FAC_DATA.PAYS_ID" could not be bound.
PS : Je cherche juste l'explication, c'est pour info seulement :D