Trying to run a mysql query from a bash shell. I cannot get a variable to pass from the shell to the sql script.
The bash shell is part of a loop that will create the new files. Below is the bash shell I have been playing with, also is the sql script that is being used. I just inherated this and am not familuar with mysql. Mysql version 5.1.34
Thanks,
John
-- part of shell --
echo $1
set swtype=$1
mysql -u root -e "set @SWTY1='${swtype}'; source /sam/sam/AGAA/agaa.complete.unload.sql;"
--- sql ---
use AGAA;
select clli,'F'
into outfile '/tmp/CLLIs.@SWTY1.West'
fields terminated by ' '
lines terminated by '\n'
from clli
where
region = 'West' and
(dev_type = '@SWTY1' or
dev_type like '@SWTY1.%') and
(clli not in (select clli from AGAA_Permanent_Exceptions));
The bash shell is part of a loop that will create the new files. Below is the bash shell I have been playing with, also is the sql script that is being used. I just inherated this and am not familuar with mysql. Mysql version 5.1.34
Thanks,
John
-- part of shell --
echo $1
set swtype=$1
mysql -u root -e "set @SWTY1='${swtype}'; source /sam/sam/AGAA/agaa.complete.unload.sql;"
--- sql ---
use AGAA;
select clli,'F'
into outfile '/tmp/CLLIs.@SWTY1.West'
fields terminated by ' '
lines terminated by '\n'
from clli
where
region = 'West' and
(dev_type = '@SWTY1' or
dev_type like '@SWTY1.%') and
(clli not in (select clli from AGAA_Permanent_Exceptions));