Basically, my question is about an approach. Currently I have a three queries which do these:
Create sale entry in DB
Create sale item in DB with sale entry id from the first query
Update stock table with a new amount for each sale item
I call of these queries one by one from Run Script action of the Button. My question is: can I have a special function which will combine all of these queries or my approach is already good enough?
I'm really new to Retool maybe I'm missing something else.
It looks like you are trying to insert a parent record, then one or more child records, and then make an update to a third table. I've just seen and responded to a similar-ish question here:
You can certainly write PL/SQL functions in your DB, or you can try something like the linked question as well, triggering each subsequent step from the success of the one before (or in a JS block).