Question: given this code: CREATE TABLE items ( itemid NUMBER ( 4 ) CONSTRAINT items _ pk PRIMARY KEY, itemname VARCHAR 2 ( 1 5 )
given this 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 put the same values in all rows : DECLARE
vprice NUMBER;
vquantity NUMBER;
vamount NUMBER;
vqrstatus VARCHAR;
BEGIN
FOR item IN SELECT itemid FROM items 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;
IF vquantity THEN
vqrstatus :C;
ELSIF vquantity BETWEEN AND THEN
vqrstatus :B;
ELSE
vqrstatus :A;
END IF;
UPDATE items
SET qrstatus vqrstatus;
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
