Home

Weak REF CURSOR types should not be used

Rule description

  • Weak REF CURSOR types should not be used

 

Non-compliant Code Example

DECLARE 
	id customers.id%type; 
	name customers.name%type; 
	address customers.address%type; 
	TYPE customers_c IS REF CURSOR;         --Non compliant code (Weak REF CURSOR types is used)
BEGIN 
   OPEN customers_c; 
   FETCH customers_c into id, name; 
      EXIT WHEN customers_c%notfound; 
      dbms_output.put_line(id || ' ' || name || ' ' || address); 
   CLOSE customers_c; 
END;

Compliant Code Example

DECLARE 
	id customers.id%type; 
	name customers.name%type; 
	address customers.address%type; 
	CURSOR customers_c is   IS REF CURSOR RETURN customers%ROWTYPE;            --Compliant code 
		
BEGIN 
   OPEN customers_c; 
   FETCH customers_c into id, name; 
      EXIT WHEN customers_c%notfound; 
      dbms_output.put_line(id || ' ' || name || ' ' || address); 
   CLOSE customers_c; 
END;
Visual Expert 2020
 VEPLSQLRULE36