Tuesday, 11 April 2017


PROCEDURE IN PL/SQL TO PRINT 1-100 PRIME NUMBER OR YOU CAN CHANGE THE VALUE AS DESIRE FOR K

CREATE OR REPLACE PROCEDURE PRIME_NUM
DECLARE
M NUMBER(5);
N NUMBER(5);
K NUMBER(5);
BEGIN
M := 2;
N := 2;
K := 100;
LOOP
LOOP
EXIT WHEN MOD(M,N) = 0 OR M = N;
N := N + 1;
END LOOP;
IF M = N THEN
DBMS_OUTPUT.PUT_LINE ( M || 'IS PRIME');
END IF;
M := M + 1;
EXIT WHEN M > K;
END LOOP;
END;
END PROCEDURE;