Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:03:44+00:00 2026-06-18T04:03:44+00:00

I am performing a very simple PL/SQL program for school. It is pretty easy

  • 0

I am performing a very simple PL/SQL program for school. It is pretty easy but I think I am missing a concept. I will show what I’ve been working on and not just ask for an easy answer. I would like to understand the concept of the DBMS_OUTPUT.PUT_LINE along with BIND variables that I have declared to calculate the volume of a rectangular prism, or a pool to say. I just don’t have it declared back properly to the user. I am having trouble finding the correct information on OUTPUT to the user, I am learning a bit more on INPUT and the put_line.

So to calc v=lwh. I have declared those variables, put in the put_line, with the dbms_output function built into PL/SQL. I applied the calculation of those variables. I am working on the dbms put line statement back to show the calculation and the concact statements with the variable dimensions displayed and how to best do that. I’ve seen this program in C language and Ruby but just not in Oracle Developer and PL/SQL.

C Language Calculate Surface Area

Java Program for Rectangular Prism

I’ll show my script and see what I’m doing incorrect, just not sure if I’m on the right track to learn better. I am having trouble displaying the dimensions and correct conc statement to display those. How to display the output to the user specifically.

Thank you for your time.

~ Write a PL/SQL block to calculate the volume of a rectangle prism swimming pool.
The dimension should be provided with the help of a bind (substitution) variable.
After the volume of the prism is calculated, display the dimensions and the volume on the screen.

v=lwh

 SET SERVEROUTPUT ON
 DECLARE
     d_length    NUMBER(7);
     d_height    NUMBER(7);  
     d_width     NUMBER(7);
     d_volume    NUMBER(15);  

BEGIN

    DBMS_OUTPUT.PUT_LINE('The length dimension is: ' || (&d_length));

    DBMS_OUTPUT.PUT_LINE('The height dimension is: ' || (&d_height));

   DBMS_OUTPUT.PUT_LINE('The width dimension is: ' ||  (&d_width));  

   d_volume := d_length * d_height * d_width;

   DBMS_OUTPUT.PUT_LINE(
   'The rectangular prism volume for the swimming pool is: ' 
   || (d_volume));   ---don't know how to get output to user

   DBMS_OUTPUT.PUT_LINE(
   'The dimensions of the swimming pool are ' || ;    ---missing code here 


 END;
 / 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:03:46+00:00Added an answer on June 18, 2026 at 4:03 am

    Bind variables and substitution variables are different things, so the problem wording is misleading. And that’s just the SQL*Plus version of bind variables; it can have a slightly different (or at least less obvious) meaning to the parser.

    Esentially you are confusing PL/SQL variables with SQL*Plus substitution variables. When you reference &d_length you are defining a substituion variable, and the user will be prompted for its value at that point. But it is completely independent from the d_length in the PL/SQL DECLARE block.

    You can look at the ACCEPT command for a neat way to get values from the user before you begin you block, but you can do it like this too:

    SET SERVEROUTPUT ON
    DECLARE
        d_length    NUMBER := &q_length;
        d_height    NUMBER := &q_height;
        d_width     NUMBER := &q_width;
        d_volume    NUMBER;
    BEGIN
        DBMS_OUTPUT.PUT_LINE('The length dimension is: ' || d_length);
        DBMS_OUTPUT.PUT_LINE('The height dimension is: ' || d_height);
        DBMS_OUTPUT.PUT_LINE('The width dimension is: ' || d_width);  
    
        d_volume := d_length * d_height * d_width;
    
        DBMS_OUTPUT.PUT_LINE(
            'The rectangular prism volume for the swimming pool is: ' 
               || d_volume);
    
       DBMS_OUTPUT.PUT_LINE(
           'The dimensions of the swimming pool are ' || '?');
    END;
    /
    

    Not sure what you want the last line of output to show; is that different from the three dimensions already shown?

    You can also do it with bind variables by defining them with the VARIABLE command:

    SET SERVEROUTPUT ON
    VARIABLE d_length NUMBER;
    VARIABLE d_height NUMBER;
    VARIABLE d_width NUMBER;
    
    DECLARE 
        d_volume    NUMBER;
    BEGIN
        :d_length := &q_length;
        :d_height := &q_height;
        :d_width := &q_width;
    
        DBMS_OUTPUT.PUT_LINE('The length dimension is: ' || :d_length);
        DBMS_OUTPUT.PUT_LINE('The height dimension is: ' || :d_height);
        DBMS_OUTPUT.PUT_LINE('The width dimension is: ' || :d_width);  
    
        d_volume := :d_length * :d_height * :d_width;
    
        DBMS_OUTPUT.PUT_LINE(
            'The rectangular prism volume for the swimming pool is: ' 
               || d_volume);
    
       DBMS_OUTPUT.PUT_LINE(
           'The dimensions of the swimming pool are ' || '?');
    END;
    /
    

    Notice that d_length, d_height and d_width are prefixed with colon in this version, because those are bind variables. But d_volume is not because that is still declared in the PL/SQL block. And the actual values are still being retrived from the user as substitution variables. This is a bit convoluted though; making them bind variables isn’t adding anything here really.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this has been answered before, but I find it very difficult to
We have a simple but very much used cache, implemented by a ConcurrentHashMap. Now
I'm having a serious problem with MySQL (innoDB) 5.0. A very simple SQL query
I'm performing a very simple onmouseover fadeTo like this: $(document).ready(function() { $('img#logo-link, a.advert').hover(function() {
I'm performing a simulation of a simple queue using SimPy . One of the
I have read these very good questions on SO about SQL stored procedures: When
All I'm trying to do is open a very simple application that is supposed
I have a very simple server/client performance test using boost::asio on Windows and it
Consider a very simple model where we have locations and each location can have
The following very simple query select distinct guid, browser_agent from tblMyGlossary where browser_agent is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.