将 DB2 查询的 return 值分配给变量
Assign return value of DB2 query to variable
我有一个文件 test.sh,其中我有一个查询,它给出了 table 中的总记录数,如下所示:
查询:
echo db2 -x "select count(*) from testable”
现在我想使用 Unix Shell 脚本将 returns 执行后的任意值分配给变量 totalRecords
。
#!/bin/bash
cnt=`db2 -x "select count(*) from syscat.tables" `
echo "Counter is: ${cnt}"
计数器是:474
我有一个文件 test.sh,其中我有一个查询,它给出了 table 中的总记录数,如下所示:
查询:
echo db2 -x "select count(*) from testable”
现在我想使用 Unix Shell 脚本将 returns 执行后的任意值分配给变量 totalRecords
。
#!/bin/bash
cnt=`db2 -x "select count(*) from syscat.tables" `
echo "Counter is: ${cnt}"
计数器是:474