Upsert using data from table

Hi, I've checked the article https://docs.retool.com/docs/sql-writes. Could you please recommend to me the article where is described how to reference both updated (several) records and the new record using Action Type "Bulk upsert via a primary key" in the "Array of records to update".

Please mind that user can behave in the following scenarios:
a) only add one new record
b) update several records
c) update several records and insert one new

The sample application is here:
Example for editing column in the table using dropdownlist.json (44.5 KB)

Thank you