InsertId in one table and insert the same id with concat of array at the end in other table
You can do this in a single statement using a data modifying CTE
with new_t1 as (
  insert into table_1 (order_id, qty)
  values ('Exak123', 59)
  returning *
)
insert into table_2 (sub_id)
select concat(t1.order_id, '_', g.nr)
from new_t1 t1
  cross join generate_series(1, t1.qty) as g(nr);