-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdate_Problem.sh
67 lines (54 loc) · 1.43 KB
/
Update_Problem.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Update_Problem - updates problem record in datebase
# Determine sql location & set variable
MYSQL=`which mysql`" Problem_Trek -u cbres"
# Obtain Record Id
if [ $# -eq 0 ]
then
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 record(s) 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
echo
echo -e "Was the problem solved today?(y/n) \c"
read ANSWER
case $ANSWER in
y|Y|YES|yes|Yes|yEs|yeS|YEs|yES)
FIXED_DATE=`date +%y%m%d`
;;
*)
echo
echo "What was the date of resolution? [YYYYMMDD] \c"
read ANSWER
FIXED_DATE=$ANSWER
;;
esac
echo
echo -e "Briefly describe the problem solution:\c"
read ANSWER
PROB_SOLUTIONS=$ANSWER
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