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\";\" ")
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...
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";
[^] # RESOLU
Posté par jukilo . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.
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 jukilo . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.
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 jukilo . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.
ç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 jukilo . En réponse au message lire et interpreter un fichier ligne par ligne. Évalué à 1.
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!