Oracle® PL/SQL® Interactive Workbook, Second Edition By Benjamin Rosenzweig, Elena Silvestrova
Table of Contents
Chapter 3. General Programming Language Fundamentals
Before starting these projects, take a look at the formatting guidelines in Appendix B. Make your variable names conform to the standard. At the top of the declaration section, put a comment stating which naming standard you are using.
Write a PL/SQL block
That includes declarations for the following variables:
A VARCHAR2 data type that can contain the string 'Introduction to Oracle PL/SQL'
A NUMBER that can be assigned 987654.55, but not 987654.567 or 9876543.55
A CONSTANT (you choose the correct data type) that is autoinitialized to the value '603D'
A DATE data type autoinitialized to one week from today
In the body of the PL/SQL block, put a DBMS_OUTPUT.PUT_LINE message for each of the variables that received an autoinitialization value.
In a comment at the bottom of the PL/SQL block, state the value of your NUMBER data type.
Alter the PL/SQL block you created in Project 1 to conform to the following specs:
Remove the DBMS_OUTPUT.PUT_LINE messages.
In the body of the PL/SQL block, write a selection test (IF) that does the following (use a nested IF statement where appropriate):
Check whether the VARCHAR2 you created contains the course named 'Introduction to Underwater Basketweaving'.
If it does, then put a DBMS_OUTPUT.PUT_LINE message on the screen that says so.
If it does not, then test to see if the CONSTANT you created contains the room number 603D.
If it does, then put a DBMS_OUTPUT.PUT_LINE message on the screen that states the course name and the room number that you've reached in this logic.
If it does not, then put a DBMS_OUTPUT.PUT_LINE message on the screen that states that the course and location could not be determined.
Add a WHEN OTHERS EXCEPTION that puts a DBMS_ OUTPUT.PUT_LINE message on the screen that says that an error occurred.
The projects in this section are meant to have you utilize all of the skills that you have acquired throughout this chapter. The answers to these projects can be found in Appendix D and at the companion Web site to this book, located at http://www.phptr.com/rosenzweig2e. Visit the Web site periodically to share and discuss your answers.