
Using the FOR-LOOP
DROP TABLEsqr_root_sum
CASCADE CONSTRAINTS PURGE;CREATE TABLE sqr_root_sum (
num NUMBER,
sq_root NUMBER(6,2),
sqr NUMBER,
sum_sqrs NUMBER);
DECLARE
s PLS_INTEGER;
BEGIN
FOR i IN 1.. 100 LOOP
s := (i * (i + 1) * (2 * i + 1)) / 6; -- sum of squares
INSERT INTO sqr_root_sum
VALUES (i,
Sqrt(i),
i * i,
s);
END LOOP;
END;
/

0 comments:
Post a Comment