In PL/SQL (or many other languages), I can have IN OUT or OUT parameters, which are returned from a procedure. How can I achieve a similar thing in Java?
I know this trick:
public void method(String in, String[] inOut, String[] inOut2) {
inOut[0] = in;
}
Where the in
parameter represents an IN parameter and the inOut
parameter can hold a return value. The convention would be that String[] inOut
is an array of inOut.length == 1
.
That's kind of clumsy.
EDIT Feedback to answers: Other tricks include:
- holder/wrapper classes, but I don't want to introduce any new types, callbacks, etc.
- return values: I'd like a general solution. I.e. one with several IN OUT parameters involved.
- wrapper for IN OUT parameter as a return value: That's a viable option, but still not so nice, because that wrapper would have to be generated somehow
Does anyone know a better way to achieve this generally? The reason I need a general solution is because I want to generate convenience source code from PL/SQL in a database schema.