title: Calling oracle function from Java JDBC
body: <p>We have a Oracle function we are trying to call from JDBC. It takes 3 inputs (String, Number and Date) and returns 1 Number:</p>
  
  <pre><code>create or replace function     mww_avgcost
  (in_prd_lvl_number prdmstee.prd_lvl_number%type,
  in_org_lvl_number orgmstee.org_lvl_number%type,
  in_sales_date     prcmstee.prc_from_date%type)
  RETURN NUMBER
  AS
  begin   
  </code></pre>
  
  <p>Using Java JDBC code as follows:</p>
  
  <pre><code>        String call = "{ ? = call PMM.MWW_AVGCOST(?, ?, ?) }";
          CallableStatement cstmt = conn.prepareCall(call);
          cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
          cstmt.setString(2, productNumber);
          cstmt.setInt(3, storeNumber);
  
          // convert XML input to SQL date
          java.sql.Date sqlDate = new java.sql.Date(saleDate.toGregorianCalendar().getTimeInMillis());
  
          cstmt.setDate(4, sqlDate);
          cstmt.execute();
          BigDecimal resultFromFunction = cstmt.getBigDecimal(1);
          log.info("resultFromFunction:" + resultFromFunction);
  </code></pre>
  
  <p>The result always returns 1 though and not the proper number. We have run it fine from SQL Developer with the same parameters and it looks fine. Is this is proper way to call a SQL function from JDBC?</p>