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

  • SEARCH
  • Home
  • 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 8927797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:17:41+00:00 2026-06-15T08:17:41+00:00

Im doing a college assignment that requires me to create a PLSQL procedure that

  • 0

Im doing a college assignment that requires me to create a PLSQL procedure that where the user can add a new customer order containing a number of items and the quantity for each item. I came up with the following that would ask the user to input a number of items to be added to the order and would then use a loop to ask for specific details such as product no and quantity. Im having problems with the user input at runtime though… When compiling the code it asks for the product code and quantity and wont ask again at runtime instead it saves the values given earlier at compile…

CREATE OR REPLACE 
PROCEDURE Add_Order (Item_amount IN NUMBER, CustNo IN NUMBER) AS

    ItemNo NUMBER; 
    var_Quantity NUMBER;
    var_PONo  NUMBER;  

    BEGIN  

      IF Item_amount BETWEEN 2 AND 9 THEN

        SELECT seq_PONo.NEXTVAL INTO var_PONo from dual;

    INSERT INTO PurchaseOrder_tab
         SELECT  var_PONo, REF(C),
                 SYSDATE,
                 ItemList_tab()
          FROM   Customer_tab C
          WHERE  C.CustNo = CustNo;

    FOR i IN 1..Item_amount LOOP
        DBMS_OUTPUT.PUT_LINE('INSIDE LOOP');
        ItemNo := &Enter_ProdCode;
        var_Quantity := &Quantity_Amount;

        INSERT INTO TABLE (
        SELECT  P.ItemList
          FROM  PurchaseOrder_tab P
         WHERE  P.PONo = var_PONo
        )

        SELECT   seq_ItemNo.nextval, REF(Pr), var_Quantity
          FROM   Products_tab Pr
         WHERE   Pr.ProductCode = ItemNo ;

        DBMS_OUTPUT.PUT_LINE('Added '||var_Quantity ||' items of '||ItemNo||' to order No: '||var_PONo);


              END LOOP;    

      ELSE

    DBMS_OUTPUT.PUT_LINE('Amount of items entered onto an order must be between 2 - 9. Please try again with correct amount.');

      END IF;

    EXCEPTION


    WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Operation failed '||'SQLCODE: '||SQLCODE);
    DBMS_OUTPUT.PUT_LINE('SQL Error Message '||SQLERRM);
    ROLLBACK;   
    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-15T08:17:42+00:00Added an answer on June 15, 2026 at 8:17 am

    Short answer: you can’t. PL/SQL is executed inside the database engine, and the database engine has no access to the terminal window (or database tool) you are using to start the procedure.

    The code in your quesion seems to partially work, because it asks for input once, but what really happens is that: the tool (SQL*Plus, SQL Developer or whatever) parses over the PL/SQL block and sees the &-Signs, so it asks what to replace them with. Once the input is given, the PL/SQL-Block – including the entered values – is given to the database for execution.

    Since you can’t do that in PL/SQL, better create a front-end program first that collects the values, then sends them to the database.

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

Sidebar

Related Questions

I am doing a college assignment in Java that deals with currency. For that
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I recently redesigned my college newspaper's website and have been doing everything I can
I am learning SQL and DB design for a college class. One assignment that
Currently doing a group project for college in Java. The assignment is to produce
I'm doing a college assignment in XNA to make a virtual piano. I have
I'm doing a project for college and have create a panel with a simple
I have the following code that I am working on for my college assignment.
I am doing college project in winform, mysql ,c#. for that I have created
I need a little bit of help. I'm doing an assignment for college at

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.