RelationalDBDesign
SiteMap
PL/SQL
Stored Objects
PL/SQL Programming
PL/SQL Datatypes
«Prev
Next»
Programming PL/SQL Objects
Declaring PL/SQL Variables
Common Tools PL/SQL
PL/SQL Variables
Variable Data Types
PL/SQL var bind host
DBMS Output Line
Creating Naming Convention
Building Queries PL/SQL
PL/SQL Datatypes
PL/SQL Block Guidelines
Variables Nested Blocks
Block Identifiers Literals
Adding PL/SQL Comments
Implicit Datatype Conversions
Operators in PL/SQL
PL/SQL Block Conclusion
PL/SQL Datatypes - Quiz
Writing Control Structures
If-then Else
Using If Clause
if then-else syntax
PL/SQL Begin Loop
For/While Loops
Labels Goto Statement
PL/SQL Control Structures
Control Structures - Quiz
Composite Datatypes
PL/SQL Table Structure
PL/SQL Record
Row Type Attributes
Composite Types Summary
Using Explicit Cursors
What is Cursor
Implicit Cursors
Explicit Cursors
CursorBlock Structure
Open Cursor Fetch Records
Close Cursor
Building Cursor Block
for Loop Cursor
Cursor Block Conclusion
PL/SQL Exceptions
PL/SQL Exception
Exception Types
Handling Predefined Exceptions
User Defined Exceptions
Raise Explicit Exceptions
Function Exceptions
PL/SQL Error Handling
Create Basic PL/SQL block- Exercise
Operators in PL/SQL
Course project: Create a basic PL/SQL block
Objective:
Create a basic PL/SQL block that uses identifiers, literals, operators, and conversion functions.
Exercise scoring
This exercise is worth a total of 30 points. You will receive up to 20 points for submitting the correct code to build the PL/SQL block. You will receive up to 5 points for documenting your code. You will receive up to 5 points for explaining whether the use of nested block is justified in this case.
Background/overview
House-O-Pets has hired you for your PL/SQL skills. Before the store can sell pets online, it requires your immediate assistance to build a PL/SQL block that will calculate the price of a pet. House-O-Pets also has some junior developers who have been discussing whether to use a nested block. You need to guide them regarding whether the use of a nested block is justified here.
Instructions
The net price of a pet is calculated by adding the price of the pet and the state tax. Both these values are passed to the PL/SQL block through SQL*Plus substitution variables. For this exercise, do the following:
Convert the state tax from a whole number to a decimal (for example, 5 to .5).
Explain whether the use of a nested block is justified in this case.
Exercise Hints
Use the
ACCEPT with PROMPT
SQL*Plus command to accept values from the user. Display the net price of the pet using
DBMS_OUTPUT.PUT_LINE (string_value)
.
Submitting your Exercise
Enter your PL/SQL block into the text box below. Click the
Submit
button to submit your answer.