jukilo a écrit 4 commentaires

  • [^] # RESOLU

    Posté par  . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.

    Au fait, j'ai trouvé mon bonheur dans

    cat monFichier | while read ligne
    do
    arg1=`echo $ligne | cut -d'_' -f1`
    arg2=`echo $ligne | cut -d'_' -f2`
    arg3=`echo $ligne | cut -d'_' -f3`

    maCommandeSQL

    done
  • [^] # Re: quel est le problème ?

    Posté par  . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.

    C'est résolu, et ça m'amène directement à un autre problème:

    system("mysql -u user -B -s -D MaBase -e \"select statut from matable where numero=4;\" ")
    fonctionne

    mais pas
    system("mysql -u user -B -s -D MaBase -e \"select statut from matable where nom='bob';\" ")
    où j'obtiens le message suvant:

    ERROR 1054 (42S22) at line 1: Unknown column 'bob' in 'where clause'
    ERROR 1054 (42S22) at line 1: Unknown column 'bob' in 'where clause'
    ERROR 1054 (42S22) at line 1: Unknown column 'bob' in 'where clause'
    ERROR 1054 (42S22) at line 1: Unknown column 'bob' in 'where clause'

    bref ça marche pour le numérique, mais pas pour les string


    j'ai essayé system("mysql -u user -B -s -D MaBase -e \"select statut from matable where nom=\'bob\';\" ")

    et system("mysql -u user -B -s -D MaBase -e \"select statut from matable where nom=\"bob\";\" ")

    mais sans résultat...
  • [^] # Re: quel est le problème ?

    Posté par  . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.

    Oh la vache merci!
    ça m'apprendra à ne pas savoir lire le man!

    En revanche ça me sort, en ayant enlevé les \ et \n:

    system(mysql -u user -B -s -D MaBase -e "select $2, $3 from $4;")

    ==>
    /bin/sh: 000select: command not found
    /bin/sh: 000select: command not found
    /bin/sh: 000select: command not found
    /bin/sh: 000select: command not found

    alors que ma commande
    $mysql -u user -B -s -D MaBase -e "select $2, $3 from $4;"
    fonctionne...
  • [^] # Re: quel est le problème ?

    Posté par  . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.

    En fait, ça me sort une string concaténée de toutes les requetes, et $requete exécute cettte concaténation.
    je souhaite exécuter une requete directement à chaque ligne et non pas une fois le fichier parcouru. (à moins qu'il y ait une meilleure solution...)

    en clair, je voufrais faire ça:
    $select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";

    $select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";

    $select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";

    et non pas
    $select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";select arg1, arg2 from arg3 where arg4="bob" and date="2006-10-31";

    Merci!