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

XQUERY/SGBD XML Discussion :

[Xquery] If then else et retour multiple


Sujet :

XQUERY/SGBD XML

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 15
    Points : 16
    Points
    16
    Par défaut [Xquery] If then else et retour multiple
    Bonjour, je rencontre un problème avec une requete Xquery sur une requete SOAP.
    donc voila mon code:
    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
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
     
    let $body :=doc("ModifierRecharge_In.xml")/*:Envelope/*:Body
    return
    <soapenv:Body   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <tuxedo:appelerTuxedo xmlns:tuxedo="*:com.bouygtel.inthd.tuxedo.ws">
        <tuxedo:serviceName>TUXRECHARGE</tuxedo:serviceName>
        <FML32>
            <TFLD_IDNVTE>{$body/*:modifierRecharge/*:in/*:VenteId/text()}</TFLD_IDNVTE>
            <TFLD_ID>{$body/*:modifierRecharge/*:in/*:IdRecharge/text()}</TFLD_ID>
            <TFLD_LGNUSR>{$body/*:modifierRecharge/*:in/*:InsertUser/text()}</TFLD_LGNUSR>
            <TFLD_CANAL>{$body/*:ConsulterRecharge/*:in/*:Canal/text()}</TFLD_CANAL>
            <TFLD_MODE_PAIEMENT>{$body/*:ConsulterRecharge/*:in/*:TypePaiement/text()}</TFLD_MODE_PAIEMENT>
            {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "RIB") then 
                <TFLD_CODE_PARAM>{$body/*:ConsulterRecharge/*:in/*:CodeRIB/text()}</TFLD_CODE_PARAM>
            else ()}
            {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "CB") then
                <TFLD_NUMCB>{$body/*:ConsulterRecharge/*:in/*:CardNum/text()}</TFLD_NUMCB>
                <TFLD_DAT_EXP>{$body/*:ConsulterRecharge/*:in/*:ExprDate/text()}</TFLD_DAT_EXP>
                <TFLD_CVV2>{$body/*:ConsulterRecharge/*:in/*:CryptoCVV2/text()}</TFLD_CVV2>
            else ()}
            {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "DAB") then
                <TFLD_IDNPTN>{$body/*:ConsulterRecharge/*:in/*:IdPartenaire/text()}</TFLD_IDNPTN>
                <TFLD_REFPAI>{$body/*:ConsulterRecharge/*:in/*:RefAutoPaiement/text()}</TFLD_REFPAI>
            else ()}
            {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "SC") then
                <TFLD_NUMCAR>{$body/*:ConsulterRecharge/*:in/*:ScNum/text()}</TFLD_NUMCAR>
            else ()}
            {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "GRATUIT") then
                <TFLD_DESC_PARAM>{$body/*:ConsulterRecharge/*:in/*:ComplInfo/text()}</TFLD_DESC_PARAM>
                <TFLD_TYP_PARAM>{$body/*:ConsulterRecharge/*:in/*:TypeAttrib/text()}</TFLD_TYP_PARAM>
                if($body/*:ConsulterRecharge/*:in/*:TypeAttrib/text() = "GSTCO") then
                    ("<TFLD_UNITE>{$body/*:ConsulterRecharge/*:in/*:NbUnit/text()}</TFLD_UNITE>
                    <TFLD_DATDEB>{$body/*:ConsulterRecharge/*:in/*:DateDebValid/text()}</TFLD_DATDEB>")
                    if( count($body/*:ConsulterRecharge/*:in/*:DateFinValid) ) then
                        <TFLD_DATFIN>{$body/*:ConsulterRecharge/*:in/*:DateFinValid/text()}</TFLD_DATFIN>
                    else <TFLD_DUREE_PERIODE>{$body/*:ConsulterRecharge/*:in/*:DureeValid/text()}</TFLD_DUREE_PERIODE>
                else ()
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:TitrePayeur)) then
                <TFLD_CIVCLIENT>{$body/*:ConsulterRecharge/*:in/*:TitrePayeur/text()}</TFLD_CIVCLIENT>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:NomPayeur) ) then
                <TFLD_NOMCLIENT>{$body/*:ConsulterRecharge/*:in/*:NomPayeur/text()}</TFLD_NOMCLIENT>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:PrenomPayeur) ) then
                <TFLD_PRENOMCLIENT>{$body/*:ConsulterRecharge/*:in/*:PrenomPayeur/text()}</TFLD_PRENOMCLIENT>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:NumeroRuePayeur) ) then
                <TFLD_NUMRUE>{$body/*:ConsulterRecharge/*:in/*:NumeroRuePayeur/text()}</TFLD_NUMRUE>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:NomRuePayeur) ) then
                <TFLD_NOMRUE>{$body/*:ConsulterRecharge/*:in/*:NomRuePayeur/text()}</TFLD_NOMRUE>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:BoitePostalPayeur) ) then
                <TFLD_BP>{$body/*:ConsulterRecharge/*:in/*:BoitePostalPayeur/text()}</TFLD_BP>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:CodePostalPayeur) ) then
                <TFLD_CP>{$body/*:ConsulterRecharge/*:in/*:CodePostalPayeur/text()}</TFLD_CP>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:VillePayeur) ) then
                <TFLD_VILLE>{$body/*:ConsulterRecharge/*:in/*:VillePayeur/text()}</TFLD_VILLE>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:CmplmtAdressePayeur) ) then
                <TFLD_COMPLEMENT>{$body/*:ConsulterRecharge/*:in/*:CmplmtAdressePayeur/text()}</TFLD_COMPLEMENT>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:TelPayeur) ) then
                <TFLD_TELDOM>{$body/*:ConsulterRecharge/*:in/*:TelPayeur/text()}</TFLD_TELDOM>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:TelProPayeur) ) then
                <TFLD_TELBU>{$body/*:ConsulterRecharge/*:in/*:TelProPayeur/text()}</TFLD_TELBU>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:CodePaysPayeur) ) then
                <TFLD_PAYS>{$body/*:ConsulterRecharge/*:in/*:CodePaysPayeur/text()}</TFLD_PAYS>
            else ()}
            {if( count($body/*:ConsulterRecharge/*:in/*:RaisonSocialPayeur) ) then
                <TFLD_RAISONSOC>{$body/*:ConsulterRecharge/*:in/*:RaisonSocialPayeur/text()}</TFLD_RAISONSOC>
            else ()}
        </FML32>
    </tuxedo:appelerTuxedo>
    </soapenv:Body>
    lorsque je fais:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "CB") then
                <TFLD_NUMCB>{$body/*:ConsulterRecharge/*:in/*:CardNum/text()}</TFLD_NUMCB>
                <TFLD_DAT_EXP>{$body/*:ConsulterRecharge/*:in/*:ExprDate/text()}</TFLD_DAT_EXP>
                <TFLD_CVV2>{$body/*:ConsulterRecharge/*:in/*:CryptoCVV2/text()}</TFLD_CVV2>
            else ()}
    j'ai une erreur du type:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Query: <P:\xxxxx\ModifierRecharge_PStoBS.xq>, line 17, column 26: [XPST0003] syntax error, unexpected "'>'", expecting "'else'"
    alors que si je modifie mon if en
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    {if($body/*:ConsulterRecharge/*:in/*:TypePaiement/text() = "CB")
    then
    <TFLD_NUMCB>{$body/*:ConsulterRecharge/*:in/*:CardNum/text()}</TFLD_NUMCB>
    else ()}
    tout marche bien, comment dois-je ecrire ma requete pour que le then puisse renvoyer plusieurs "ligne"?


    Merci d'avance

  2. #2
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 15
    Points : 16
    Points
    16
    Par défaut
    bon je me repond à moi même,

    donc pour pouvoir retourner plusieurs expression, la syntaxe est

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    for $prod in (doc("Data.xml")/order/car)
    return if ($prod/@model = 'ACC')
           then (<accessoryid>{data($prod/id)}</accessoryid>,
                <accessoryName>{data($prod/name)}</accessoryName>)
           else <otherid>{data($prod/id)}</otherid>
    donc parenthèse, et virgule.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] if...then...else
    Par jive dans le forum ASP
    Réponses: 5
    Dernier message: 16/09/2005, 14h11
  2. [TagLib] Structure if then else
    Par mush_H dans le forum Taglibs
    Réponses: 5
    Dernier message: 19/07/2005, 15h31
  3. If Then Else
    Par Piout dans le forum MS SQL Server
    Réponses: 13
    Dernier message: 24/02/2005, 16h09
  4. IF THEN ELSE imbriqués
    Par nuke_y dans le forum Oracle
    Réponses: 2
    Dernier message: 15/11/2004, 14h57
  5. [CR 7] [débutante] pb avec if then else
    Par xs_nady dans le forum Formules
    Réponses: 8
    Dernier message: 28/05/2004, 15h36

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