Hi,
I am having very little sucess in trying to get a stored proc run from a Bash script via MySql with the MySql command and the SQL being held in variables.
e.g.
The statement to fire against the MySQL database transposes the command to;
So the question is how to be able to get the vale of the variable SQL in one set of single quotes including spaces.
Thanks
RB
I am having very little sucess in trying to get a stored proc run from a Bash script via MySql with the MySql command and the SQL being held in variables.
e.g.
The echo statement returns;# Defining SQL connection and SQL
MYSQL_SERVER="192.168.1.1"
MYSQL_DB="dbname"
MYSQL_READER="user1"
MYSQL_RPW="user1pw"
MYSQL_COMMAND="mysql -h$MYSQL_SERVER -u$MYSQL_READER -p$MYSQL_RPW $MYSQL_DB -e"
SQL="call sp_name;"
# Call SQL
echo $MYSQL_COMMAND $SQL
SQL_RETURN=`$MYSQL_COMMAND $SQL`
which is correct.mysql -h192.168.1.1 -uuser1 -puser1pw dbname -e 'call sp_name;'
The statement to fire against the MySQL database transposes the command to;
which is wrong (note the single quotes seperating the 'call' and the 'sp_name' sections).mysql -h192.168.1.1 -uuser1 -puser1pw dbname -e ''\''call' 'sp_name;'\'''
So the question is how to be able to get the vale of the variable SQL in one set of single quotes including spaces.
Thanks
RB