Index | Home | Forums
Oracle PL/SQL Example 4-19 Using a Simple GOTO Statement

Example 4-19 Using a Simple GOTO Statement

DECLARE
  p        VARCHAR2(30);
  n        PLS_INTEGER := 37; -- test any integer > 2 for prime
BEGIN
  FOR j in 2..ROUND(SQRT(n)) LOOP
    IF n MOD j = 0 THEN -- test for prime
      p := ' is not a prime number'; -- not a prime number
      GOTO print_now;
    END IF;
  END LOOP;
  p := ' is a prime number';

<<print_now>>
  DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) || p);
END;
/


This page was generated on/at Feb 23,2008 00:20:12
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here




Index | Home | Forums
Oracle PL/SQL Example 4-19 Using a Simple GOTO Statement

Example 4-19 Using a Simple GOTO Statement

DECLARE
  p        VARCHAR2(30);
  n        PLS_INTEGER := 37; -- test any integer > 2 for prime
BEGIN
  FOR j in 2..ROUND(SQRT(n)) LOOP
    IF n MOD j = 0 THEN -- test for prime
      p := ' is not a prime number'; -- not a prime number
      GOTO print_now;
    END IF;
  END LOOP;
  p := ' is a prime number';

<<print_now>>
  DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) || p);
END;
/


This page was created by oracleabc.com on Feb 23,2008 00:09:02
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here