Skip to content
Advertisement

Optimize Merge query inside n^2 loop

I’ve got a merge query that needs to be executed one time for each combination of day and sessionType inside the request ArrayList. I am using nativeQuery to execute it.

Is there a way to plain the source data (two ArrayLists, one with a date range instead a single day, and the other with all the session types), so I can execute the merge just one time? I have been told this can be achieved using a WITH but I have no idea how to do it.

Any help would be appreciated.

Advertisement

Answer

  1. you can use executeBatch: in this case oracle executes your sql statement on the input array automatically

  2. you can bind a collection and use it in table() like this:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement