LINUX的SHELL脚本中中执行数据库语句
语句:TEST="db2\"updateTBL_DRP_DEPLOYsetSITE='BEIJING'whereREC_ID=1731andFUNC_ID='C03010...
语句:
TEST=" db2 \"update TBL_DRP_DEPLOY set SITE='BEIJING' where REC_ID=1731 and FUNC_ID='C0301016'\" "
$TEST
执行结果:
drpbj:/DRONLAPS/usr/dr_onlas/hanxiao >EIJING' where REC_ID=1731 and FUNC_ID='C0301016'\" " <
drpbj:/DRONLAPS/usr/dr_onlas/hanxiao >$TEST
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following
"FUNC_ID='C0301016'"". Expected tokens may include: "JOIN <joined_table>".
SQLSTATE=42601
但是单独执行就没问题
drpbj:/DRONLAPS/usr/dr_onlas/hanxiao >db2 "update TBL_DRP_DEPLOY set SITE='BEIJING' where REC_ID=1731 and FUNC_ID='C0301016'"
DB20000I The SQL command completed successfully.
请大神帮我指点一下,是不是脚本中套一个带数据库SQL语句的参数时,转义符的问题
另外,我比如在脚本中用文件去逐行读取这个数据库语句,所以不能单独写出来
谢谢
另外,我必须在脚本中用文件去逐行读取这个数据库语句,所以不能单独写出来
谢谢 展开
TEST=" db2 \"update TBL_DRP_DEPLOY set SITE='BEIJING' where REC_ID=1731 and FUNC_ID='C0301016'\" "
$TEST
执行结果:
drpbj:/DRONLAPS/usr/dr_onlas/hanxiao >EIJING' where REC_ID=1731 and FUNC_ID='C0301016'\" " <
drpbj:/DRONLAPS/usr/dr_onlas/hanxiao >$TEST
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following
"FUNC_ID='C0301016'"". Expected tokens may include: "JOIN <joined_table>".
SQLSTATE=42601
但是单独执行就没问题
drpbj:/DRONLAPS/usr/dr_onlas/hanxiao >db2 "update TBL_DRP_DEPLOY set SITE='BEIJING' where REC_ID=1731 and FUNC_ID='C0301016'"
DB20000I The SQL command completed successfully.
请大神帮我指点一下,是不是脚本中套一个带数据库SQL语句的参数时,转义符的问题
另外,我比如在脚本中用文件去逐行读取这个数据库语句,所以不能单独写出来
谢谢
另外,我必须在脚本中用文件去逐行读取这个数据库语句,所以不能单独写出来
谢谢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |