Reputation: 225
Hi I am calling an SP from Java code. This SP has 50+ input parameters. So I set
ct.setInt(1, id);
like this from 1 to 50. So if i need to remove say 4th parameter, i need to change all the numbers manually which is a tedious process. Is there any good way to implement this? Some loop way where we dont need to manually change the parameter number?
Upvotes: 2
Views: 213
Reputation: 262764
Ideally, you can use named parameters (which I know may not work too well with all databases/drivers).
Or you could do
int i = 1;
ct.setInt(i++, id);
// ct.setObject(i++, old); // removed line, everything renumbers itself
ct.setString(i++, somethingElse);
ct.setString(i++, evenMore);
to keep track of the index.
Upvotes: 2