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
Building PL/SQL Block
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
PL/SQL Control Structures
For/While Loops
Control Structures - Quiz
Composite Datatypes
PL/SQL Table Structure
PL/SQL Record
Row Type Attributes
Composite Types Explained
Using Explicit Cursors
Implicit Cursor Guidelines
Explicit Cursor Guidelines
PL/SQL Exceptions
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.
Submit