Thursday, November 11, 2010

Returning VARCHAR/String from a PLSQL call in Application Module

Well, not all the time you want a CURSOR

    public String getNextReferenceNumber(String loanTypeCode) {

        CallableStatement callableStatement = null;
        String s = "BEGIN ? := xxhls_housing_loan_pkg.get_next_reference_number_fn(?); END;";

        try {

            callableStatement = getOADBTransaction().createCallableStatement(s, -1);
            callableStatement.registerOutParameter(1, OracleTypes.VARCHAR);
            callableStatement.setString(2, loanTypeCode);
            callableStatement.execute();
           
            return ((OracleCallableStatement)callableStatement).getString(1);
          
        } catch (Exception sqlexception) {

            throw new OAException(sqlexception.getMessage());

        } finally {

            try {
                if (callableStatement != null)
                    callableStatement.close();               
            } catch (SQLException sqlexception1) {
                throw new OAException(sqlexception1.getMessage());
            }

        }

    }

No comments:

Post a Comment