Précédent   Forum des professionnels en informatique > Bases de données > Oracle > SQL
SQL Forum d'entraide sur le SQL pour Oracle
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 28/10/2011, 12h00   #1
Candidat au titre de Membre du Club
 
Inscription : juillet 2007
Messages : 59
Détails du profil
Informations personnelles :
Âge : 29

Informations forums :
Inscription : juillet 2007
Messages : 59
Points : 10
Points : 10
Par défaut Requête + inner join+ update

j 'ai une requête en access :
Code :
1
2
3
4
5
6
7
 
UPDATE T_AxeFH_RPC
INNER JOIN (COORD_XY_G2R INNER JOIN TVal_DO_Region ON COORD_XY_G2R.nodep = TVal_DO_Region.Departement) 
ON T_AxeFH_RPC.Site_B = COORD_XY_G2R.nosite 
SET 
T_AxeFH_RPC.DO = [TVal_DO_Region]![DO],
 T_AxeFH_RPC.Région = [TVal_DO_Region]![Région];
je viens de la changer en oracle de cette façon, mais tjs ca ne fonctionne pas:

Code :
1
2
3
4
5
6
7
8
9
10
 
 
UPDATE T_AxeFH_RPC  ( SELECT reg.DO AS do  , reg.Region AS region
          FROM T_AxeFH_RPC T_RPC
          INNER JOIN (COORD_XY_G2R coord INNER JOIN (TVal_DO_Region reg) ON coord.nodep = reg.Departement ) 
          ON T_RPC.Site_B = coord.nosite
          )
SET
T_AxeFH_RPC.DO = DO,
T_AxeFH_RPC.Region =  Region;
Merci d'avance.
zorro13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/10/2011, 14h50   #2
Membre habitué
 
Homme Gaëtan
Développeur Oracle
Inscription : mai 2006
Messages : 117
Détails du profil
Informations personnelles :
Nom : Homme Gaëtan
Localisation : France

Informations professionnelles :
Activité : Développeur Oracle
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : mai 2006
Messages : 117
Points : 115
Points : 115
Bonjour,

Je pense que ceci devrait marcher si le block

Code :
1
2
3
4
SELECT * 
            FROM COORD_XY_G2R coord
          INNER JOIN TVAL_DO_REGION REG ON COORD.NODEP = REG.DEPARTEMENT 
          WHERE T_RPC.Site_B = coord.nosite
ne ramène qu'une seul ligne

Code :
1
2
3
4
5
6
7
8
9
10
11
12
UPDATE T_AxeFH_RPC T_RPC
SET
T_RPC.DO =  ( SELECT REG.DO  
            FROM COORD_XY_G2R coord
          INNER JOIN TVAL_DO_REGION REG ON COORD.NODEP = REG.DEPARTEMENT 
          WHERE T_RPC.Site_B = coord.nosite
          ),
T_RPC.REGION =  ( SELECT REG.REGION  
            FROM COORD_XY_G2R coord
          INNER JOIN TVAL_DO_REGION REG ON COORD.NODEP = REG.DEPARTEMENT 
          WHERE T_RPC.Site_B = coord.nosite
          )
attila771 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/10/2011, 15h05   #3
Expert Confirmé
 
Homme
Inscription : mai 2002
Messages : 1 641
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 29
Localisation : France, Rhône (Rhône Alpes)

Informations forums :
Inscription : mai 2002
Messages : 1 641
Points : 2 634
Points : 2 634
Oula vous ne faites pas la même chose là.

Attila ta requete est même dangereuse, selon la relation entre ces tables on risque de se retrouver avec plein de null dans T_AxeFH_RPC !!


Sinon pour répondre à la question initiale, pour les updates :
http://lnavarro.developpez.com/oracle/updatemerge/


edit :
Code :
1
2
3
4
5
6
7
8
 
UPDATE (
	SELECT T_RPC.do AS rpc_do, reg.DO AS do  , T_RPC.region AS rpc_reg, reg.Region AS region
	FROM T_AxeFH_RPC T_RPC
	INNER JOIN COORD_XY_G2R coord ON T_RPC.Site_B = coord.nosite
	INNER JOIN TVal_DO_Region reg ON coord.nodep = reg.Departement 
	)
SET rpc_do = do, rpc_reg = region;
Code :
1
2
3
4
5
6
7
8
9
 
merge INTO T_AxeFH_RPC a
USING (
	SELECT coord.nosite, reg.DO, reg.Region; 
	FROM COORD_XY_G2R coord
	INNER JOIN TVal_DO_Region reg ON coord.nodep = reg.Departement
	) b
ON (a.Site_B = b.nosite)
when matched then UPDATE SET a.do = b.do, a.region = b.region;
punkoff est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/10/2011, 15h47   #4
Membre habitué
 
Homme Gaëtan
Développeur Oracle
Inscription : mai 2006
Messages : 117
Détails du profil
Informations personnelles :
Nom : Homme Gaëtan
Localisation : France

Informations professionnelles :
Activité : Développeur Oracle
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : mai 2006
Messages : 117
Points : 115
Points : 115
Oupsss en effet je n'ai pas pensé au valeur Null possible désolé.
attila771 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/10/2011, 16h26   #5
Candidat au titre de Membre du Club
 
Inscription : juillet 2007
Messages : 59
Détails du profil
Informations personnelles :
Âge : 29

Informations forums :
Inscription : juillet 2007
Messages : 59
Points : 10
Points : 10
Merci ça marche
zorro13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h08.


 
 
 
 
Partenaires

Hébergement Web