Q:

PL/SQL needing some direction

This is the question:  You want to determine how many of a particular item can be purchased given the amount you have to spend. Clearly you need to establish the item price and how much you have to spend. The result on the screen should tell how many of that item you can purchase. 
This is the table I created:
SQL> select *
 2  from product2;

 PIDNO PNAME                PCOST
---------- --------------- ----------
  1111 Pencil                   1
  2222 Soda                     5
  3333 Cards                    2

This is the code:
       SET SERVEROUTPUT ON
     ACCEPT input_money PROMPT 'Enter how much money you have: '
  DECLARE
v_pidno product2.pidno%TYPE;
v_pname product2.pname%TYPE;
v_pcost product2.pcost%TYPE;
v_money number(3);
 BEGIN
 SELECT pidno, pname, pcost
INTO v_pidno, v_pname, v_pcost
FROM product2
WHERE pidno = v_pidno;
V_money :=v_money/v_pcost;
 dbms_output.put_line ('How much you can buy is: ' ||v_money);
END;
 /
  SET SERVEROUTPUT OFF

I also have the code written this way:
  SET SERVEROUTPUT ON
  ACCEPT input_pidno PROMPT 'Enter product ID: '
  DECLARE
  v_pidno product2.pidno%TYPE;
  v_pname product2.pname%TYPE;
 v_pcost product2.pcost%TYPE;
 v_money number(3);
 BEGIN
   SELECT pidno, pname, pcost
 INTO v_pidno, v_pname, v_pcost
 FROM product2
 WHERE pidno = &input_pidno;
 V_money :=v_money/v_pcost;
 dbms_output.put_line ('How much you can buy is: ' ||v_money); 
END;
/
SET SERVEROUTPUT

I want to be able too type in how much money I have and a pidno and it tell me how many I can buy. I just do not know how to re word this code. 

A:

You're accepting a monetary quantity and putting it into a PIDNO. This is probably not what you wanted. Try something like:
SET SERVEROUTPUT ON

ACCEPT input_money PROMPT 'Enter how much money you have: '
ACCEPT input_pidno PROMPT 'Enter the product ID you want: '

DECLARE
  v_pidno         product2.pidno%TYPE;
  v_pname         product2.pname%TYPE;
  v_pcost         product2.pcost%TYPE;
  v_items_to_buy  number(3);
BEGIN
  SELECT pidno, pname, pcost
    INTO v_pidno, v_pname, v_pcost
    FROM product2
    WHERE pidno = &input_pidno;

  v_items_to_buy := &input_money / v_pcost;

  dbms_output.put_line ('You can buy ' || v_items_to_buy || ' ' || v_pname); 
END;
/
SET SERVEROUTPUT OFF

Best of luck.

