There is no reason, in this case, even in Oracle to use Insert All
. The values
are defined variables in a procedural block (pl/sql), they are not derived from the select following. So there is no reason you need a single statement in Postgres. 2 Inserts within a procedural block (plpgsql) will accomplish exactly the same. So
declare ...
begin
...
insert into mytable1 (empid, name, last_name)
values (expr1, expr2, expr_n);
insert into mytable2 (empid, address)
values (o_expr1, o_expr2, o_expr_n);
...
end;
Would do exactly the same. And IMHO easier to understand than DML within a CTE.
NOTE:
As written these will not run in Oracle nor in Posrgres. The insert for mytable2
names 2 columns to be inserted, but contains 3 values. Those must match. I am guessing this is a copy/paste error.