Question: given the following code:CREATE TABLE items ( itemid NUMBER ( 4 ) CONSTRAINT items _ pk PRIMARY KEY, itemname VARCHAR 2 ( 1 5 )

given the following code:CREATE TABLE items (
itemid NUMBER(4) CONSTRAINT items_pk PRIMARY KEY,
itemname VARCHAR2(15),
price NUMBER,
quantity NUMBER,
amount NUMBER,
q_r_status VARCHAR2(15)
);
2)
INSERT INTO items (itemid, itemname) VALUES (111,'A');
INSERT INTO items (itemid, itemname) VALUES (222,'B');
INSERT INTO items (itemid, itemname) VALUES (333,'C');
INSERT INTO items (itemid, itemname) VALUES (444,'D');
INSERT INTO items (itemid, itemname) VALUES (555,'E'); why does this code fill all rows with the first input : DECLARE
v_price items.price%type;
v_quantity items.quantity%type;
v_amount items.amount%type;
v_q_r_status items.q_r_status%type;
CURSOR allitems is
SELECT * FROM items;
BEGIN
FOR item IN allitems LOOP
DBMS_OUTPUT.PUT('Enter price for item '|| item.itemid ||': ');
v_price := &v_price;
DBMS_OUTPUT.PUT('Enter quantity for item '|| item.itemid ||': ');
v_quantity := &v_quantity;
v_amount := v_price * v_quantity;
UPDATE items
SET price = v_price,
quantity = v_quantity,
amount = v_amount
WHERE itemid = item.itemid;
IF v_quantity <50 THEN
v_q_r_status :='C';
ELSIF v_quantity BETWEEN 50 AND 100 THEN
v_q_r_status :='B';
ELSE
v_q_r_status :='A';
END IF;
UPDATE items
SET q_r_status = v_q_r_status
WHERE itemid = item.itemid;
DBMS_OUTPUT.PUT_LINE('Item '|| item.itemid ||', Price: '|| v_price ||', Quantity: '|| v_quantity ||', Amount: '|| v_amount ||', Q/R Status: '|| v_q_r_status);
END LOOP;
END;
/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!