Home

SIMPLE_INTEGER should be used instead of PLS_INTEGER

Rule description

  • SIMPLE_INTEGER should be used instead of PLS_INTEGER

 

Non-compliant Code Example

DECLARE
  num  VARCHAR2(50);
  counter  PLS_INTEGER := 81;            --Non compliant code (PLS_INTEGER is used instead of SIMPLE_INTEGER)
BEGIN
  FOR i in 2..ROUND(SQRT(counter))
	LOOP
    IF counter MOD i = 0 THEN
      num := ' is not a prime number';
      GOTO print_now;
    END IF;
  END LOOP;

  num := ' is a prime number';
 
<<print_now>>
  DBMS_OUTPUT.PUT_LINE(TO_CHAR(counter) || num);
END;

Compliant Code Example

DECLARE
  num  VARCHAR2(50);
  counter  INTEGER := 81;            --Non compliant code (SIMPLE_INTEGER is used instead of PLS_INTEGER)
BEGIN
  FOR i in 2..ROUND(SQRT(counter))
	LOOP
    IF counter MOD i = 0 THEN
      num := ' is not a prime number';
      GOTO print_now;
    END IF;
  END LOOP;

  num := ' is a prime number';
 
<<print_now>>
  DBMS_OUTPUT.PUT_LINE(TO_CHAR(counter) || num);
END;
Visual Expert 2020
 VEPLSQLRULE151