我有一个直接从数据库中选择计数的ksh脚本。我用一个存储过程调用替换它。我的存储过程选择一个OUT变量。
如何将OUT值捕获到我的脚本中声明的数据文件中?
{{1}}
EOF
答案 0 :(得分:1)
你可以尝试这个。 lv_status应该给你out参数。
##Procedure Execution starts
procname=$your_user_name."your_proc_name"
echo $procname
echo $procname |grep "("
if [ $? -eq 0 ]
then
procname=`echo $procname|cut -f1 -d")"`",lv_status)";
else
procname=`echo $procname`"(lv_status)";
fi
echo "Executing $procname"
bteq <<EOF
.logon $tdpid/db_user_name,db_password
.EXPORT FILE=$tempfile
.SET WIDTH 3000
.SET TITLEDASHES OFF;
CALL $procname;
.EXPORT RESET;
.LOGOFF
.EXIT
EOF
exit_status=$?
lv_status=`tail +2 $tempfile`
rm -f $tempfile
if [ $lv_status ]
then
if [ $lv_status = "FAILED" -o $exit_status -ne 0 ]
then
echo "Error in executing procedure $procname";
exit 1;
fi
else
echo "The procedure does not have the mandatory OUT status parameter. Consider remodeling the code for full error trapping"
exit 1
fi
echo "Procedure $procname completed successfully"