I would like to pass a value of a user-defined parameter to mysql console and use it as following:
example.sql:
SELECT (@somevar + 1) as my_sum;
usage example:
C:>bin\mysql -utest -p --xml **{somehow @somevar:=100}** < example.sql
<?xml version="1.0"?>
<resultset statement="SELECT (@somevar + 1) as my_sum"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="my_sum" xsi:nil="true" />
</row>
</resultset>
Is it possible?
Re your comment:
Yes, it’s odd that it’s not documented. But you can see it with
mysql --help. You can also try it like I did, and see that it works.I have logged a bug to ask for this option to be added to the manual.
http://bugs.mysql.com/bug.php?id=63672