Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / December 2005

Tip: Looking for answers? Try searching our database.

Call Oracle Stored Procedure from Java with less arguments

Thread view: 
Christian Schmidbauer - 23 Dec 2005 13:40 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.