title: Calling an Oracle SQL function
body: <p>I'm new to the connectivity between Java and Oracle and I'm designing a login page.</p>
  
  <p>I'm attempting to call an Oracle function from JAVA.  Assume the Oracle function is called <code>FUNCT_PERSON</code> with 2 IN parameters: <code>username</code> and <code>password</code> and return the user id which is a <code>NUMBER</code>.</p>
  
  <p>Inside the <code>FUNCT_PERSON</code> function we use a <code>SELECT</code> statement and return user id number if found, otherwise it will return 0.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>String sql = "{ ? = call FUNCT_PERSON(?,?) }";
  CallableStatement statement = connection.prepareCall(sql);
  statement.setString(2,username);
  statement.setString(3,password);
  statement.registerOutParameter(1, java.sql.Types.INTEGER);  
  
  Boolean check = statement.execute();   
  
  if (!check) {
   //proceed to another page
  } else {
   //Go back to the login page
  }
  </code></pre>
  
  <p>I don't know if what I'm doing is right or not, especially the <code>Boolean check = statement.execute();</code> line, because I don't really know what the check is for..</p>
  
  <p>If the function return a user ID, that means it exists in the database and I'll proceed to another page. If not, then it will redirect to the login page.</p>