• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to pass a NULL parameter in prepareCall method.

 
Pooja Agarwal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All

I have got a problem in invoking a stored procedure from java code,

The Java code is:
-----------------

cstmt = connection.prepareCall("{call INSERTUPSDEMO(?, ?, ?, ?, ?)}");

cstmt.setString(1, "SAM");
cstmt.setInt(2, 2000);
cstmt.setInt(3, 250);
cstmt.setInt(4, 3467);

cstmt.registerOutParameter (5, Types.INTEGER);
cstmt.execute();
temp = cstmt.getInt(5); // Get the output parameter values

My Problem:
-----------

The code works fine if i give all the parameters.
But in some cases i may not pass all the parameters,
for example if i dont want to send the parameter4 value,
i.e i want to send a null value into it.
I need to know how to pass a null parameter.


Any help is appreciated,
Thanks in advance,
Pooja
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36007
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pooja,
You need to call setNull(). Sun has a section in their tutorial on this.
 
Pooja Agarwal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Jeanne,

Thanks a lot for ur help.
It worked fine with setNull() method.

Thanks once again,
Pooja.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!