What is the PostgreSQL equivalent to the TSQL “go” statement?
I have a query to insert a record into a table
--something like this
Insert into employee values(1,'Mike');
GO n;
I want this query to be executed n number of times.
This is possible without reverting to PL/pgSQL:
Insert into employee (id, name)
select 1,'Mike'
from generate_series(1,3);
Or if you want different IDs for each row:
Insert into employee (id, name)
select id,'Mike'
from generate_series(1,3) as t(id);
https://xzilla.net//blog/2020/Nov/Do-This-10-Times-And-Stop-dot-dot-dot-In-Postgres.html
select $$Insert into emp values(1,'Mike') $$ from generate_series(1,10) \gexec
only applicable to psql https://www.postgresql.org/docs/current/app-psql.html