-- This application imports the abstract interface dixie_abs_interface -- and the abstract domain packages to access the dixie_db data base. with dixie_employee_def_pkg; use dixie_employee_def_pkg; -- Step 1 with dixie_salary_def_pkg; use dixie_salary_def_pkg; with dixie_abs_interface; use dixie_abs_interface; with text_io; use text_io; with string_pack; use string_pack; procedure dixie_application is -- Step 2 personnel_record : emp_rec; -- Step 3 business_record : sal_rec; id_number : employee_id_not_null; -- Step 4 -- merit_pts_nn is used for type conversion between the null bearing -- points_type and the non null bearing points_not_null so that the -- assign procedure can be used on a variable of this type merit_pts_nn : points_not_null; error_result : valid_status_result_type; -- Step 5 boolean_result : boolean; -- Step 6 -- Variables and instantiations for general program use -- Step 7 valid_code : boolean := false; option_entry : character; exit_code : constant character := '8'; see_employ_code : constant character := '1'; add_job_code : constant character := '2'; new_sal_code : constant character := '3'; commit_code : constant character := '4'; rollback_code : constant character := '5'; release_screen : character; weight_image, string_holder : string(1..100) := (others => ' '); last : natural; trash : string (1..1) := (others => ' '); package integer_io is new text_io.integer_io(integer); package real_io is new float_io(float); use real_io; -- This function gets the option code (either access dixie_db or exit -- the program) from the operator. function option_input return character is begin valid_code := false; while not valid_code loop text_io.put_line(" "); put_line("Please enter an option number. Either: "); put_line("1 : to view a record from the employees table or"); put_line("2 : to add one year to years employed in the job_hist table or"); put_line("3 : to insert a new record into the salary_hist table"); put_line("4 : to commit the transaction"); put_line("5 : to rollback the transaction"); put_line("8 : to exit this program."); put_line(" "); put("Enter option here => "); get (option_entry); text_io.get_line(trash, last); case option_entry is when see_employ_code => valid_code := true; when add_job_code => valid_code := true; when new_sal_code => valid_code := true; when commit_code => valid_code := true; when rollback_code => valid_code := true; when exit_code => valid_code := true; when others => put("Invalid option. Type 'C' and press to continue."); get(release_screen); end case; end loop; return option_entry; end option_input; begin -- The main program will loop until the operator requests option 8 or exit. put_line("**********Welcome to the Dixie_Db upadate program**********"); put_line(" "); startup; loop if option_input = exit_code then exit; elsif option_entry = see_employ_code then put_line("Please enter an employee id number => "); string_holder := (others => ' '); text_io.get_line(string_holder, last); move(strip(string_holder), string(id_number)); open_emp_cursor(id_number,error_result); if error_result = cursor_already_open then close_emp_cursor; text_io.put_line("Try again"); else emp_fetch(personnel_record, error_result); if error_result = row_not_found then text_io.put_line("No employee with this number found"); else real_io.put(weight_image, float(personnel_record.emp_weight), 2,0); text_io.put_line(strip(string(personnel_record.emp_id)) & " " & strip(string(personnel_record.emp_lastname)) & " " & strip(string(personnel_record.emp_firstname)) & " " & strip(string(personnel_record.emp_address)) & " " & strip(weight_image)); end if; end if; close_emp_cursor; put_line(" "); elsif option_entry = add_job_code then put_line("Please enter an employee id number => "); string_holder := (others => ' '); text_io.get_line(string_holder, last); move(strip(string_holder), string(id_number)); add_year(id_number, boolean_result); if boolean_result = false then text_io.put_line("Year not updated"); end if; elsif option_entry = new_sal_code then put_line("Enter an employee id number (5 characters) .. not null => "); string_holder := (others => ' '); text_io.get_line(string_holder, last); move(strip(string_holder), string(business_record.new_emp_id)); put_line("Enter earnings for employee (0.00 to 99000.00) .. not null =>"); real_io.get(float(business_record.new_emp_sal)); text_io.get_line(trash, last); put_line ("Enter merit points for employee (0 to 99) .. return for null => "); string_holder := (others => ' '); text_io.get_line(string_holder,last); if last = 0 -- they are inputting a null then points_ops.assign(business_record.new_emp_pts, null_sql_int); else integer_io.get(string_holder, integer(merit_pts_nn), last); points_ops.assign (business_record.new_emp_pts, points_ops.with_null(merit_pts_nn)); end if; new_sal_row(business_record, error_result); elsif option_entry = commit_code then keep_it; elsif option_entry = rollback_code then trash_it; end if; end loop; end dixie_application;