Hello!
I have a Oracle stored procedure which accepts e. g. 7 parameters which
describe the columns being updated in the database. Simplified it looks
like that:
PROCEDURE modify(
nr IN OUT NUMBER,
name IN CHAR,
address IN CHAR,
city IN CHAR,
birthday IN DATE,
errfield IN OUT CHAR,
iret IN OUT NUMBER );
Now I intend to update only the "address". The other data doesn't
change and shouldn't be updated.
Lines in Java:
-------------------------------------------------------------
OracleCallableStatement cstmt =
(OracleCallableStatement) _connection.prepareCall
("{call modify(?, ?, ?, ?, ?, ?, ?)}");
cstmt.registerOutParameter(1, OracleTypes.NUMBER);
cstmt.registerOutParameter(6, OracleTypes.CHAR);
cstmt.registerOutParameter(7, OracleTypes.NUMBER);
cstmt.setInt(1, 10); // nr
cstmt.setString(3, "New Street 1"); // address
-------------------------------------------------------------
I mustn't set the other parameters because every parameter which is set
updates the corresponding value in the database.
But: The result from the program is:
--> No value specified for parameter 2
When I'm doing a "cstmt.setNull(...)" with the missing parameters the
database values are going to be deleted.
Does anybody know how to bypass this problem?
Thanks in advance,
Christian
Joe Weinstein - 23 Dec 2005 15:58 GMT
> Hello!
>
[quoted text clipped - 40 lines]
> Thanks in advance,
> Christian
Yes. Rewrite the procedure to understand that null values of
parameters mean not to change the relevant column values.
Java can't help you get around the semantics of your procedure.
HTH,
Joe Weinstein at BEA Systems