WITH par_key AS (INSERT INTO participante (nome) VALUES ('Laurenz') RETURNING id), ven_key AS (INSERT INTO venda (inicio) VALUES (current_date) RETURNING id), item_key AS (INSERT INTO item (nome) VALUES ('thing') RETURNING id) INSERT INTO lances_vendas (venda_id, item_id, participante_id, valor) SELECT ven_key.id, item_key.id, par_key.id, numeric '3.1415' FROM par_key, ven_key, item_key;