I would like to insert some values in this way:
with first_insert as (
insert into stacks(press_id,quantita_a,quantita_b,quantita_c)
values($press_id,
coalesce((select something),-1),
coalesce((select something),-1),
coalesce((select something),-1))
RETURNING id_stack,qty_a,qty_b,qty_c
)
insert into stacks_panels_ct(id_stack,panel_read_id)
(select id_stack,panel_read_id from pile_wip
join first_insert on true
where press_id=$press_id2 and stack_number=$stack_number)
select qty_a,qty_b,qty_c from first_insert
and at the end of the second insert, I would like to return (for third-party use) the values of qty_a, qty_b and qty_c.
Everything works fine except for the last SELECT
, which does not work at all.
Using RETURNING
in place of the last SELECT
does not work.
I am using timescaledb:2.3.0-pg13 (Timescale 2.3.0 on Postgres 13)
Thanks in advance, Fabio