7 ms·
You can do them individually yes, but you can’t do INSERT and UPDATE from the same SELECT CTE. Before, you’d have to either load the data in the client side or
by gen220 4y ago
You can do them individually yes, but you can’t do INSERT and UPDATE from the same SELECT CTE.
Before, you’d have to either load the data in the client side or duplicate the CTE across two statements in a transaction.
- nicoburns 4y agoYou can, like this: WITH results as ( SELECT ... ), inserted_rows AS ( INSERT ... SELECT * FROM results ... ), deleted_rows AS ( DELETE ... USING results ... ) UPDATE ... FROM results
- gen220 4y agoWoah! I stand corrected, thanks. It seems you’re knowledgeable on this, do you know if MERGE useful beyond expressivity?