I'm using Retool to manage data entry for a PostgreSQL DB. In particular, I have a form that allows me to add many products at once. The form also allows selecting a tag that would apply to all these products.
I've been struggling when trying to achieve the following:
- Create rows (batch insert) for all products in the form upon submission
- Tag those new products. Since there is a many-to-many relationship between products and tags, I need to do a second batch insert in the product_tag table.
My initial idea to solve it was to capture the ID of each newly created product (first query) and somehow run a second query –triggered by the success of the first one– in which a second batch insert would take place. However, I seem unable to access the set of newly created product ids from the first query.
Any ideas on how to overcome this?