title: PLSQL Procedure get user input at runtime
body: <p>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...</p>
  
  <pre><code>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 := &amp;Enter_ProdCode;
          var_Quantity := &amp;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;
      /
  </code></pre>