"Raquel" <ra****************@yahoo.com> wrote in message
news:9a**************************@posting.google.c om...
Have a question on the Stored procedure method code generated by DB2
development center for Java stored procedures.
Suppose I have a requirement to return the resultset consisting of
FIRSTNME, LASTNAME of all employees belonging to a particular
department, following is the stored procedure method code generated by
"DB2 development center":
public static void sproc3mtd ( String workdept,
String[] firstnme,
String[] lastname,
String[] errorlabel,
ResultSet[] rs1 ) throws Exception
In reality, only the following method would have sufficed:
public static void sproc3mtd ( String workdept,
String[] errorlabel,
ResultSet[] rs1 ) throws Exception
This is because FIRSTNME and LASTNAME are generated in the resultset
itself and so, no explicity declaration for them needs to be done in
the stored procedure method.
Does anyone know why DB2 development center generates this redundant
code?
I haven't used the Development Center yet so this is just a guess; however,
assuming that the Development Center is similar to the Stored Procedure
Builder in earlier versions of DB2, it is probably because you've specified
firstname and lastname in the query that you entered in the wizard. You can
prove this by creating a few more simple stored procedures and see if every
column specified in the query that is specified in the wizard appears in the
parameter list for your method.
If I'm right, you can prevent the unwanted column names from being generated
in the parameter list by revising the query so that firstnme and lastname
columns are not mentioned in the query. I don't know if that's possible in
your particular case; if it isn't possible, you should be able to delete the
extra column names from the parameter list manually after the stored
procedure is generated. I do major edits of the stored procedure code all
the time in the Stored Procedure Builder without problems: if you change the
parameters, the Builder will ask whether you want to replace the original
version of the procedure or create a new one; you just click the appropriate
button and the Builder does the rest.
Rhino