I want to make specific .sql
file for each of my routines.
#!/bin/bash
routine_names=$(mysql mydb --execute="SELECT
*
FROM
information_schema.routines
WHERE
routine_type = 'PROCEDURE' OR routine_type ='FUNCTION'
AND routine_schema = 'mydb';"|cut -f1)
for routine in "$routine_names"
do
if [ -e "${routine}.sql" ]
then
echo "ok"
else
content_procedure=$(mysql mydb--execute="SHOW CREATE PROCEDURE $routine;")
echo "$content_procedure" >> masoud.txt
fi
done
my routine_names
variable is a list of my procedures. like this:
SP_ONE
SP_TWO
SP_THREE
I want to loop of these result. but I think the result is not an array. because routine
variable has all content.
2条答案
按热度按时间wko9yo5t1#
wrap your
mysql mydb ...
command with()
I was curious and got the idea from here .
xqkwcwgp2#
Just another case how I fix my problem