DECLARE
TYPE T_RECORD IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
V_RESULT T_RECORD;
I NUMBER DEFAULT 3;
N NUMBER DEFAULT 0;
BEGIN
--DBMS_OUTPUT.PUT_LINE(2);
V_RESULT(1) := 3;
WHILE (I < 100) LOOP
FOR J IN 1 .. V_RESULT.COUNT LOOP
IF V_RESULT(J) * V_RESULT(J) > I THEN
--DBMS_OUTPUT.PUT_LINE(I);
V_RESULT(V_RESULT.COUNT + 1) := I;
EXIT;
END IF;
IF TRUNC(I / V_RESULT(J)) = I / V_RESULT(J) THEN
EXIT;
END IF;
END LOOP;
IF N = 2 THEN
I := I + 4;
N := 1;
ELSE
I := I + 2;
N := N + 1;
END IF;
END LOOP;
V_RESULT(0) := 2;
END;
--参考:
http://www.itpub.net/thread-922955-1-1.html