Home > Articles > Data > Oracle

  • Print
  • + Share This
This chapter is from the book

Test Your Thinking

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.

  1. Write a PL/SQL block

    1. 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 auto-initialized to the value '603D' A BOOLEAN

      A DATE data type autoinitialized to one week from today

    2. 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.

    3. In a comment at the bottom of the PL/SQL block, state the value of your NUMBER data type.

  2. Alter the PL/SQL block you created in Project 1 to conform to the following specs:

    1. Remove the DBMS_OUTPUT.PUT_LINE messages.

    2. In the body of the PL/SQL block, write a selection test (IF) that does the following (use a nested IF statement where appropriate):

      1. Check whether the VARCHAR2 you created contains the course named 'Introduction to Underwater Basketweaving'.

      2. If it does, then put a DBMS_OUTPUT.PUT_LINE message on the screen that says so.

      3. If it does not, then test to see if the CONSTANT you created contains the room number 603D.

      4. 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. on the screen that states that the course and location could not be determined.

  3. 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.

  • + Share This
  • 🔖 Save To Your Account