MSCEWI3130
For Loop and Fetch into a variable cannot be used on the same cursor
Severity
Description
Example Code
Input Code
CREATE OR REPLACE PROCEDURE PROC01
AS
var1 NUMBER;
record_product products%ROWTYPE;
CURSOR c_product IS SELECT price FROM products;
BEGIN
OPEN c_product;
FETCH c_product INTO var1;
CLOSE c_product;
OPEN c_product;
LOOP
FETCH c_product INTO record_product;
EXIT WHEN c_product%NOTFOUND;
INSERT INTO sold_items VALUES record_product;
END LOOP;
CLOSE c_product;
END;Output Code
Recommendations
Last updated
