I need to do the following task, using
JDBC (I can't use database triggers or constraints with cascade-delete)
As you can see the result of the first query is used again and again. Is there a way to cache the result and use it in the subsequent statements?
Of course, I can use an ArrayList to store the MESSAGE_IDs returned in (a), but there are 2 problems with the approach
i) The number of rows returned is huge and so it storing it in a ArrayList and retriving it [I]might[/] affect the performance
ii) I have to format the ArrayList entries in a way that it can be passed into the subsequent queries. (I have to fetch the individual elements in the ArrayList, append them all with a comma inbetween them...). Looks awkward to me.
Just wondering, is there a way to do it elegantly?