IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SQL Oracle Discussion :

update qui fait pas son boulot !


Sujet :

SQL Oracle

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Avril 2007
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 3
    Points : 1
    Points
    1
    Par défaut update qui fait pas son boulot !
    bonjour,
    la version d'oracle utilisée est 8i.

    voici mon problème, quand j'essaye de faire l'update suivant, il m'affiche 0 update, alors que si j'execute juste le code en bleu, il me ramène bel et bien une ligne.
    j'aimerais avoir votre avis.

    update table1
    set flag =1
    where
    (cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER) in

    (

    select cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER
    from
    (select cdsg,montant,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER,count(flag)
    over(partition by cdsg,montant order by datoper,noper) nbr
    from table1 where
    COPER = 'W22' and
    cdsg = 457 and
    radic =777125 and
    serie =587 and
    datoper ='23/05/2006' and
    noper =173 and
    (cdsg,montant) in (select cdsg,montant*-1 from
    table1 where coper='RTD'
    and flag=1)
    )
    where nbr=1

    )
    je pourrais pas changer le contenu du code, mais j'aimerais juste connaitre pourquoi l'update ne marche pas.

    merci

  2. #2
    Rédacteur

    Homme Profil pro
    Développeur et DBA Oracle
    Inscrit en
    Octobre 2006
    Messages
    878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur et DBA Oracle

    Informations forums :
    Inscription : Octobre 2006
    Messages : 878
    Points : 1 197
    Points
    1 197
    Par défaut
    salut,

    IL faut utiliser # pour mettre ton code .

    Tu peux poster le script de création et des insertions?

  3. #3
    Membre expert
    Avatar de LeoAnderson
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 2 938
    Points : 3 199
    Points
    3 199
    Par défaut
    Combien de lignes sont retournées par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
    select * from table1
    where
    (cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER) in
     
    (
     
    select cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER
    from
    (select cdsg,montant,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER,count(flag)
    over(partition by cdsg,montant order by datoper,noper) nbr
    from table1 where
    COPER = 'W22' and
    cdsg = 457 and
    radic =777125 and
    serie =587 and
    datoper ='23/05/2006' and
    noper =173 and
    (cdsg,montant) in (select cdsg,montant*-1 from
    table1 where coper='RTD'
    and flag=1)
    )
    where nbr=1
    c'est à dire avoir un select qui comporte EXACTEMENT la même clause where que l'update.

    Ceci étant, j'espère que ce genre d'update est "one-shot" parce qu'un select de select, lui-même filtré par un select, le tout utilisé en clause where in.... on fait mieux pour les perfs !!

  4. #4
    Nouveau Candidat au Club
    Inscrit en
    Avril 2007
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Citation Envoyé par LeoAnderson
    Combien de lignes sont retournées par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
    select * from table1
    where
    (cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER) in
     
    (
     
    select cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER
    from
    (select cdsg,montant,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER,count(flag)
    over(partition by cdsg,montant order by datoper,noper) nbr
    from table1 where
    COPER = 'W22' and
    cdsg = 457 and
    radic =777125 and
    serie =587 and
    datoper ='23/05/2006' and
    noper =173 and
    (cdsg,montant) in (select cdsg,montant*-1 from
    table1 where coper='RTD'
    and flag=1)
    )
    where nbr=1
    c'est à dire avoir un select qui comporte EXACTEMENT la même clause where que l'update.

    Ceci étant, j'espère que ce genre d'update est "one-shot" parce qu'un select de select, lui-même filtré par un select, le tout utilisé en clause where in.... on fait mieux pour les perfs !!
    dans le cas cité, y a une seule ligne retournée par le select. mais dés que j'utilise le résultat pour la requete update ,ben ça donne 0 update !

  5. #5
    Membre expert
    Avatar de LeoAnderson
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 2 938
    Points : 3 199
    Points
    3 199
    Par défaut
    pouvez-vous coller les instructions SQL passées et le retour ?

  6. #6
    Nouveau Candidat au Club
    Inscrit en
    Avril 2007
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 3
    Points : 1
    Points
    1
    Par défaut toujours dans le flou
    le code suivant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    select * where 
    (cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER) in
    (
    select cdsg,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER 
    from
    (select cdsg,montant,RADIC,SERIE,NORDR,CDMONN,DATOPER,NOPER,COPER,count(flag) 
    over(partition by cdsg,montant order by datoper,noper) nbr 
    from table1 where
    COPER = 'W22' and  cdsg = 457 and  radic =777125 and 
    serie =587 and  datoper ='23/05/2006' and  noper =173 and 
    (cdsg,montant) in (select cdsg,montant*-1 from 
    table1 where coper='RTD' 
    and flag=1) 
    )
    where nbr=1
    )
    me donne zero update

    par contre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    select * from table1
    where cdmonn=0 and COPER='W22' and  cdsg=457 and  radic=777125 and 
    serie=587 and  datoper='23/05/2006' and  noper=173 and
    me donne bien la ligne recherché.
    et c'est exactement la ligne qui est rendu par le code en bleu de mon premier message!

Discussions similaires

  1. Etape de filtrage ne fait pas son boulot
    Par xmamet dans le forum kettle/PDI
    Réponses: 0
    Dernier message: 16/12/2014, 13h09
  2. clamav fait pas son boulot
    Par gilles974 dans le forum Sécurité
    Réponses: 4
    Dernier message: 15/06/2011, 13h30
  3. opérateur > qui fait pas son job
    Par LDDL dans le forum Requêtes
    Réponses: 1
    Dernier message: 27/04/2010, 10h31
  4. noRouteAction ne fait pas son boulot?
    Par pyd001 dans le forum MVC
    Réponses: 4
    Dernier message: 14/02/2007, 00h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo