'Loop over a table then use a function to retrieve the data then insert each row to another table

Table has data like this

2302    20201124-000000000024
2302    20201124-000000000025
2302    20201124-000000000026
2302    20201124-000000000027

Loop through the table with the data with two columns listed above

insert into trade_invoice ( clientid, clientname, invoicedate, amount )
from
select * generate_invoice(2302, '20201124-000000000024') 

end loop


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source