我正在寻找从我写的SQL中的“count”变量中返回一个数值。不幸的是,我只是得到一个安格尔错误消息。任何想法我做错了什么?在shell脚本中将表计数设置为变量..?
见shell脚本代码如下:
#!/bin/ksh
###############
count=$(sql db_name -s -N "SELECT COUNT(*) FROM temp_table;")
echo "Table count = $count"
见安格尔错误如下:
Table count = INGRES TERMINAL MONITOR Copyright 2008 Ingres Corporation
E_US0022 Either the flag format or one of the flags is incorrect,
or the parameters are not in proper order.
预期成果:
Table count = 8
如果您使用的是Korn shell中,使用'ksh'标签,而不是'bash'标签。无论如何,这不是一个壳问题。你的SQL命令有问题。 – chepner
您是否尝试过执行'sql db_name -s-N“SELECT COUNT(*)FROM temp_table;”'查看脚本之外的输出是什么? – Fred