MSCEWI3130
For Loop and Fetch into a variable cannot be used on the same cursor
This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
Medium
Description
This warning appears when the same cursor declaration is used in a fetch statement into a variable, a loop, or a fetch into records. In this case, the use of fetch into variables is commented out.
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
To support both scenarios, duplicating the cursor declaration is recommended so that each statement will use a separate cursor.
If you need more support, you can email us at [email protected]
Last updated
