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 CONSTRAINT itemspk PRIMARY KEY,
itemname VARCHAR
price NUMBER,
quantity NUMBER,
amount NUMBER,
qrstatus VARCHAR
;
INSERT INTO items itemid itemname VALUES A;
INSERT INTO items itemid itemname VALUES B;
INSERT INTO items itemid itemname VALUES C;
INSERT INTO items itemid itemname VALUES D;
INSERT INTO items itemid itemname VALUES E; why does this code fill all rows with the first input : DECLARE
vprice items.pricetype;
vquantity items.quantitytype;
vamount items.amounttype;
vqrstatus items.qrstatustype;
CURSOR allitems is
SELECT FROM items;
BEGIN
FOR item IN allitems LOOP
DBMSOUTPUT.PUTEnter price for item item.itemid : ;
vprice : &vprice;
DBMSOUTPUT.PUTEnter quantity for item item.itemid : ;
vquantity : &vquantity;
vamount : vprice vquantity;
UPDATE items
SET price vprice,
quantity vquantity,
amount vamount
WHERE itemid item.itemid;
IF vquantity THEN
vqrstatus :C;
ELSIF vquantity BETWEEN AND THEN
vqrstatus :B;
ELSE
vqrstatus :A;
END IF;
UPDATE items
SET qrstatus vqrstatus
WHERE itemid item.itemid;
DBMSOUTPUT.PUTLINEItem item.itemid Price: vprice Quantity: vquantity Amount: vamount QR Status: vqrstatus;
END LOOP;
END;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
