Announcement Announcement Module
Collapse
No announcement yet.
Problem using in out parameter using spring storedprocedure class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem using in out parameter using spring storedprocedure class

    Hi I am invoking an oracle stored procedure which takes an in out parameter. I am invoking the the procedure from my class which extends from spring's StoredProcedure class.Based on number of posts I have declared the inout parameter as out parameter in my class and also passed a value to the parameter in my mapping function. The problem is that it works only as a out parameter but not as in parameter.Can someone tell me what I might be doing wrong?
    Code:
    public class MyService extends StoredProcedure { 
    public MyService(JdbcTemplate jdbcTemplate,String sqlString) {
         setJdbcTemplate(jdbcTemplate);
         setSql(sqlString);     setFunction(false);
         declareParameter( new SqlOutParameter("inoutparam",OracleTypes.INTEGER));
        declareParameter( new SqlParameter("inparam",Types.VARCHAR));
        compile();
    }
     public Map execute(int arg1,String arg2) {
       Map<String, Object> inParams = new HashMap<String, Object>();
       inParams.put("inoutparam", arg1);
       inParams.put("inparam", arg2);
       Map<String,Object> map = execute(inParams);
       return map;
    }
    }
    Code:
    PROCEDURE prc_my_proc (
      inoutparam  IN OUT NUMBER, 
     inparam             VARCHAR2)
     IS
     BEGIN
      INSERT INTO save_log values ( inoutparam,sysdate); 
    inoutparam := 100; 
    END prc_my_proc;
    Last edited by bobbi80; Aug 29th, 2012, 02:53 AM.

  • #2
    Hello

    Next time use code tags, Would you post the complete error stack trace? (if any), with that we have a more clear idea
    of the problem.

    Comment


    • #3
      Hi,

      There is no error.
      Let me just eloborate a little :
      In execute() method I set "inoutparam" to 50 before invoking the oracle function.
      In the oracle function I log the value of inoutparam to a table called "save_log" which always displays the value as null.
      I am changing the value of "inoutparam" to 100 and if I printthe value on return from oracle function call then it correctly prints 100.
      In essence INOUT param is working just as an OUT parameter and not as inteneded.
      Hope it clarifies my problem!

      Comment


      • #4
        resolved by Using SqlInOutParameter . Thanks..
        Code:
        declareParameter( new SqlInOutParameter("inoutparam",OracleTypes.INTEGER));

        Comment

        Working...
        X