Running .sql files in postgres (structured programs)
The equivalent of Oracle's anonymous PL/SQL blocks are anonymous PL/pgSQL blocks in Postgres. These are started using the do statement:

do
$$
declare 
  ....
begin
  .... 
end;
$$