Sunday February 5th 2012

Insider

Archives

¿Como llamar a una función PL/SQL desde java?

 

Aquí les dejo la función para que puedan ocuparla.

   1:  //Recibe como parámetro un String y retorna un String
   2:   
   3:        private String ExtraerFuncion(String usercode) throws SQLException, Exception, Error{
   4:   
   5:              String sql = "", dato="";           
   6:              sql = "{? = call FN_RETURN_FUNCION(?)}";           
   7:              CallableStatement cs = null;
   8:   
   9:              try
  10:              {
  11:                  cs = sessionManager.getConnection().prepareCall(sql);
  12:                  cs.registerOutParameter(1, Types.VARCHAR);
  13:                  cs.setString(2, usercode);
  14:                  cs.execute();
  15:                  dato = cs.getString(1);
  16:              }
  17:              catch (Exception e)
  18:              {
  19:                  e.printStackTrace();
  20:              }
  21:              finally
  22:              {
  23:                   cs.close();
  24:              }
  25:              return dato;
  26:          }

Reader Feedback

One Response to “¿Como llamar a una función PL/SQL desde java?”

Leave a Reply


Warning: Invalid argument supplied for foreach() in /home/content/w/h/i/whibla1/html/wp-content/plugins/smilies-themer-toolbar/smilies-themer-toolbar.php on line 450