Procedural code is only allowed inside a DO
statement or a function body.
Using the default procedural language PL/pgSQL (but there are many other options):
DO
$do$
BEGIN
FOR i IN 1..100 LOOP
INSERT INTO "MYSHM".aaa -- column definition list ?!
VALUES (i, i + 1, i + 2, i + 3);
END LOOP;
END
$do$;
Or, better, recast your problem as set-based operation with generate_series()
:
INSERT INTO "MYSHM".aaa -- column definition list ?!
SELECT i, i + 1, i + 2, i + 3
FROM generate_series(1,100) i;