Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Sunday 18 November 2012

Write a Script for Simple Database Management System Operation


clear
echo "\nDATABASE MANAGEMENT SYSTEM OPERATION\n"
echo "-----------------------------------------"
echo "1. VIEW RECORD BASES ON QUERY"
echo "2. ADD RECORD"
echo "3. DELETE RECORD"
echo "4. COUNT TOTAL NUMBER OF RECORD"
echo "5. EXIT"
echo "Enter your choice"
read ch
case $ch in
1)
echo " * Serching Record * "
echo "1. EMP_NO"
echo "2. EMP_NAME"
echo "3. EMP_ADDRESS"
echo "4. EMP_AGE"
echo "5. EMP_GENDER"
echo "6. EMP_DESIGNATION"
echo "7. EMP_BASIC_SALARY"
read serch_choice
case $serch_choice in
1)
echo "Enter Employee NO "
read empno
empno=`expr $empno + 1`

head -$empno emp.txt > temp1

tail -1 temp1 > temp2
no= `awk '{print $1}' temp2`
echo $no
;;
2)
echo "Enter Employee's Name"
read empname
grep "$empname" emp.txt
;;
3)
echo "Enter Address"
read empadd
grep "$empadd" emp.txt
;;
4)
echo "Enter Age"
read age
grep "$age" emp.txt
;;
5)
echo "Enter Gender"
read gender
grep "$gender" emp.txt
;;
6)
echo "Enter Designation"
read empdesig
grep "$empdesig" emp.txt
;;

7)
echo "Enter Basic Salary"
read bs
grep "$bs" emp.txt
;;
8)
echo "wrong choice"
;;
esac
;;
2)
echo "Enter emp_no : "
read empno
echo "Enter emp_name : "
read empname
echo "Enter address : "
read empadd
echo "Enter age : "
read age
echo "Enter Gender : "
read gender
echo "Enter designation : "
read empdesig
echo "Enter basic salary : "
read bs
record="$empno|$empname|$empaddr|$age|$gender|$empdesig|$bs"
`echo $record>>emp.txt`
echo " \t Record insert successfully..."
;;
3)
echo "Enter name"
read name
#`sed "/$name/d" emp.txt>tempfile1`
`grep -w "/$name/d" emp.txt>tempfile1`
`cat tempfile1>emp.txt`
rm tempfile1
  echo "\t Record delete successfully..."
;;
4) echo "Enter name"
read name
`sed "/$name/d" emp.txt>tempfile1`
`cat tempfile1>emp.txt`
rm tempfile1
echo "Enter emp_no : "
read empno
echo "Enter emp_name : "
read empname
echo "Enter address : "
read empadd
echo "Enter age : "
read age
echo "Enter Gender : "
read gender
echo "Enter designation : "
read empdesig
echo "Enter basic salary : "
read bs
record="$empno|$empname|$empaddr|$age|$gender|$empdesig|$bs"
`echo $record>>emp.txt`
echo " \t Record modify successfully..."
;;
Esac

No comments:

Post a Comment