For every inserted row, generate series of rows in another table with AFTER INSERT trigger in PostgreSQL Let's say that a customer places an order with certain quantity and I want to insert this information into table1 initialy. At the same time, I want to generate a series of  rows in the table2 with a combination of the newly generated ID in table1. Has to be executed for every new order. Like:
Table 1 
columns - id ,qty
          A1   25
          A2   32

Generates:
Table 2 
column - sub_id 
          A1_1
          A1_2
          .
          .
          A1_25
          A2_1
          A2_2
          .
          .
          A2_32
This is likely best handled in application code since it's a procedural goal you're trying to accomplish, not really a relational one, since the approach likely requires iteration.
That being said, you possibly can accomplish it in a relational way via Dynamic SQL if you had a numbers table you could select the TOP N number of rows from prepended with your id. The Dynamic SQL comes into play as a way to build the query with N = your qty field.
E.g. the query that your Dynamic SQL could generate would look like this (with id and qty filled in):
SELECT CONCAT('A1', '_', Number) AS sub_id
FROM NumbersTable
ORDER BY Number
LIMIT 25