Reputation: 2840
I'm making call to mysql procedure and it is failing with the error below. I am unable to figure it out what is the issue.
My shell script snippet is below:
export batchsize=$1
echo $batchsize
myvar=$(mysql -q mydb -uuser --skip-column-names --execute='call delete_table_incrementally(batchsize)')
Code snippet from mysql procedure is below:
create procedure delete_table_incrementally(IN batchsize MEDIUMINT(3))
modifies sql data
begin
DELETE FROM mytable where mycondition='ERROR-5000' order by id limit batchsize;
commit;
select count(*) FROM mytable where mycondition='ERROR-5000';
end;
//
delimiter ;
call delete_table_incrementally();
Error code/response from mysql which executing bash script is:
ERROR 1054 (42S22) at line 1: Unknown column 'batchsize' in 'field list'
Any ideas would be appreciated.
Upvotes: 1
Views: 75
Reputation: 85600
The way you are using your bash
variable is incorrect, use double-quotes("
) to expand variables i.e. something like:
mysql -q mydb -uuser --skip-column-names --execute="call delete_table_incrementally($batchsize)"
Upvotes: 1