Results 1 to 4 of 4

Thread: Problem using in out parameter using spring storedprocedure class

  1. #1
    Join Date
    Aug 2012
    Posts
    3

    Default 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 at 01:53 AM.

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,795

    Default

    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.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Aug 2012
    Posts
    3

    Default

    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!

  4. #4
    Join Date
    Aug 2012
    Posts
    3

    Default

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •