码迷,mamicode.com
首页 > 数据库 > 详细

9>>problem-record-mysql

时间:2015-06-06 00:23:01      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

#!/bin/bash
#
# Update_Problem - updates problem record in database
###############################################################
# Determine sql location & set variable
#
MYSQL=`which mysql`" Problem_Task -u testuser"
#
################################################################
#
if [ $# -eq 0 ] #Check if id number was passed.
then
#
# Check if any unfinished records exist.
#
RECORDS_EXIST=`$MYSQL -Bse ‘select id_number from problem_logger where
fixed_date="0000-00-00" or prob_solutions=""‘`
#
#
if [ "$RECORDS_EXIST" != "" ]
then
echo
echo "The following records need updating..."
$MYSQL <<EOF
select id_number,report_date,prob_symptoms
from problem_logger
where fixed_date="0000-00-00" or
prob_solutions=""\G
EOF
fi
echo
echo "What is the ID number for the"
echo -e "problem you want to update?:\c"
read ANSWER
ID_NUMBER=$ANSWER
else
ID_NUMBER=$1
fi
#
################################################################
# Obtain Solution (aka Fixed) Date
#
echo
echo -e "Was problem solved today?[y/n] \c"
read ANSWER
#
case ANSWER in
y|Y|yes|Yes|yEs|yeS|YEs|yES|YeS|YES)
FIXED_DATE=`date +%Y-%m-%d`
;;
*)
#if answer is anything but yes,ask for date
echo
echo -e "What was the date of resolution?[YYYY-MM-DD]\c"
read ANSWER
#
FIXED_DATE=$ANSWER
;;
esac
#
###############################################################
# Acquire problem solution
#
echo
echo -e "Briefly describe the problem solution :\c"
#
read ANSWER
PROB_SOLUTIONS=$ANSWER
#
##############################################################
# Update problem record
#
#
echo
echo "Problem record updated as follows:"
echo
$MYSQL <<EOF
UPDATE problem_logger SET
prob_solutions="$PROB_SOLUTIONS"
fixed_date=$FIXED_DATE
WHERE id_number=$ID_NUMBER
#
select * from problem_logger where id_number=$ID_NUMBER\G
EOF
#
#END

9>>problem-record-mysql

标签:

原文地址:http://www.cnblogs.com/wyw248325496/p/4555799.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!