The idea is, to generate complex and large sql merge statement with a function
Just copy the contents of the file merge_generator to your sql editor. Then replace the 2 variables with the target schema and table name.
Run the whole thing. The output contains the generated merge statement where you need to make only litle modifications.
Feel free to contact me for any questions.
Good luck, Jens