
 CREATE OR REPLACE PROCEDURE Receive_Inventory
      (item_id_in IN NUMBER,
       quantity_in IN INTEGER)
    AS
       record_count NUMBER;
       num_in_stock NUMBER;
    BEGIN
        SELECT COUNT(*)
         INTO record_count
        FROM Inventory
	    WHERE Item_id = item_id_in;

        IF record_count <> 1 THEN
            RAISE VALUE_ERROR;
        END IF;

        IF quantity_in < 1 THEN
            RAISE VALUE_ERROR;
        END IF;

        SELECT Number_in_Stock
         INTO num_in_stock
        FROM Inventory
        WHERE Item_id = item_id_in;

        num_in_stock := num_in_stock + quantity_in;

        UPDATE Inventory
          SET Number_in_Stock = num_in_stock
        WHERE Item_id = item_id_in;

    END;

    COMMIT;


    SELECT * FROM Inventory WHERE Item_Id = 12;

    CALL Receive_Inventory(12, 4);

