#!/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's 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 and yes,ask for date
Echo
Echo-e "What is 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