- 论坛徽章:
- 0
|
本帖最后由 红狐狸 于 2011-06-21 12:22 编辑
类似:
. $DB2INSTPATH/sqllib/db2profile
db2 connect to icmnlsdb
exec_sql "select INVOICE_DAY-WARN_DAY ,SURE_DAY-WARN_DAY, INVOICE_DAY, SURE_DAY from t_pub with ur " 1
if [ "$sqlstat" != "02000" ]; then
fpts=`echo "$SDATA" | sed -e '4,/^$/!d;/^$/d' |awk '{print $1 }' `
fi
exec_sql ()
{
if [ $# -ne 2 ];then
echo -e "时间[`date "+%Y%m%d%T"`] : SQL语句[ "$1" ]缺少执行参数...">> sql.log
exit 1
fi
SQL="$1"
SDATA=`db2 -a "$SQL"`
sqlstat=`echo "$SDATA" | sed -n -e 's/^.*sqlstate: *\([0-9,a-z,A-Z][0-9,a-z,A-Z]
*\).*/\1/p'`
if [ "$sqlstat" != "00000" -a "$sqlstat" != "02000" ]
then
echo -e "\n===================================================================
=============">>sql.log
echo -e "时间[`date "+%Y%m%d%T"`] : 请检查SQL语句是否正确执行......">>sql.log
echo -e "SQL 语句 : [ "$1" ]\n\n执行情况 : [ "$SDATA" ]\n\n第二参数 : [ "$2" ]
">>sql.log
echo -e "\n第二参数说明:">>sql.log
echo -e " =1 : 退出执行">>sql.log
echo -e " =0 : 继续执行">>sql.log
echo -e "=====================================================================
===========">>sql.log
if [ $2 -ne 0 ];then
exit 1
fi
fi
}
我想这个对你一定有帮助,格式,你自己搞一搞 |
|