PL/SQL Datatypes  «Prev  Next»

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:
  1. Convert the state tax from a whole number to a decimal (for example, 5 to .5).
  2. 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.