Home
>
Articles
>
Data
>
Oracle
This chapter is from the book
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
-
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
-
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.
|
2) |
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://authors.phptr.com/rosenzweig3e. Visit the Web site periodically to share and discuss your answers.
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
-
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
-
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.
|
2) |
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://authors.phptr.com/rosenzweig3e. Visit the Web site periodically to share and discuss your answers.