Announcement Announcement Module
Collapse
No announcement yet.
Return value of stored procs using StoredProcedure class and not SimpleJdbcCall. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Return value of stored procs using StoredProcedure class and not SimpleJdbcCall.

    Hi,
    I am using Spring 3.1.1 . I would like to konw how I can retrieve a return value from a stored proc. My stored proc returns errorcodes. I have read that this can be done using SimplejdbcCall, but I want to avoid doing this. I am more inclined to use Spring StoredProcedure class. It has provision for IN and OUT parameters but cant seem to find a way to get return value. Can return value to retrieved using StoredProcedure class? If not, Is SimpleJdbcCall the only way to retrieve stored proc return values or can this be done in any other way.

    Thanks,
    Dn.

  • #2
    Ok fixed this. For others encountering the same problem, Here is the solution . use setFunction(true) and declare the return param as the first parameter as shown below. The name of the param should be same as the name of the return variable in the stored proc, though I am not very sure about this. Then the return parameter can be accessed as any other out parameter in the return Map.

    public MyStoredProc(JdbcTemplate jdbcTemplate) {
    super(jdbcTemplate, "mystoredproc");
    setFunction(true);
    declareParameter(new SqlOutParameter("Result", Types.NUMERIC));

    declareParameter(new SqlInOutParameter("otherparam1", Types.INTEGER));
    declareParameter(new SqlParameter("otherparam2", Types.INTEGER));
    allowsUnusedParameters();
    compile();
    }
    Last edited by dna; Mar 13th, 2012, 12:57 PM.

    Comment

    Working...
    X