Project 7: Advanced SQL*Plus Scripting
After completing this lab you should be able to:
- Use variables in a sqlplus script.
- Prompt a user for values in a sqlplus script.
- Call operating system commands from a sqlplus script.
- This type of sqlplus scripting is acceptable for use in the final project.
Also useful for this lab will be running UNIX shell commands like cls.
- Review and/or lookup these commands in your appendix:
- SET VERIFY
- COLUMN, HEADING, FORMAT
You can put !cls in your script to clear the screen.
Due for Project 7
Turn in the SQL file used to produce the script pictured in figures 1, 2, and 3.
Lab Assignment Steps
- Your guidelines are to make your script mimic the following screen captures.
Figure 1 - First prompt the user for employee id, name, and title information.
Figure 2 - Next, prompt the user for the department. Also, show all valid departments. This is important since there is a Referential Integrity constraint on the employee table which requires valid department IDs.
Figure 3 - Next, prompt the user for the employee's supervisor. As with department id, show all valid supervisors (assume titles are equal to 'Director' or 'Manager'). Finally, insert the row into the EMPLOYEE table with the information provided by the user.
- OPTIONAL STEP: Before terminating the script you should ask the user if they want to enter data for another employee. Add to your sqlplus script the commands to restart if the user types Y for yes after an appropriate prompt.