Re: Call Oracle Stored Procedure from Java with less arguments





Christian Schmidbauer wrote:
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

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

.



Relevant Pages

  • Call Oracle Stored Procedure from Java with less arguments
    ... I have a Oracle stored procedure which accepts e. ... describe the columns being updated in the database. ... When I'm doing a "cstmt.setNull" with the missing parameters the ... Does anybody know how to bypass this problem? ...
    (comp.lang.java.databases)
  • data view web part with custom query
    ... I would like to call an Oracle stored procedure from the Custom Query of a ... I have tried entering the SP name and "execute sp_name") but just get "the ... The SP executes fine in an Oracle environment, and the database is reachable ...
    (microsoft.public.frontpage.programming)
  • How to execute stored procedure?
    ... I would like to execute an oracle stored procedure using the any ... oracle database module which satisfies the Database Specification ... standard. ... I have tried cxOracle and Odbc database packages with no ...
    (comp.lang.python)
  • RE: I want to use oracle stored procedure
    ... Oracle Stored Procedure in Visual C# .NET" ... John Paul. ... > database and run the stored procedure in oracle. ...
    (microsoft.public.dotnet.general)
  • RE: SQL injection ( and being a pen tester means being good in every area)
    ... Regarding the mentioned error you receive - it seems like the ' char is ... I'm doing a pentest for a client's web app: ... IP address of the database server itself. ... Securing Web Applications ...
    (Pen-Test)