我遇到从命令行调用存储过程的问题。它在Workbench中运行得非常好,但是从命令行执行的相同的SQL(我想在cron中定期使用bash脚本调用它)只会发出错误。
这是我在Workbench中执行的内容:
CALL hourly_summary('20150309',04);
哪个运行正常。
以下是我从CLI执行的内容:
$ mysql -h <REMOVED> -u <REMOVED> -p<REMOVED> netflow -e "CALL hourly_summary('20150309',04);"
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
我试图摆弄查询的不同引号,我也试过进入MySQL CLI但它仍然失败。
$ mysql -h <REMOVED> -u <REMOVED> -p<REMOVED> netflow
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3654
Server version: 5.6.22-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CALL hourly_summary('20150309',04);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
mysql> exit
Bye
我不知道在Workbench和CLI中运行它有什么不同?
04故意不在单引号之间。它是程序中的整数。
答案 0 :(得分:0)
您的程序内容是什么?我觉得那里有些不好
btw,参考最后一个答案,sqlcmd是一个mssql的东西
答案 1 :(得分:-1)
无法从命令行调用sp?
sqlcmd -E -S server_name -d database_name -Q "EXEC schema.spname param1, param2"
试试这可能有效