当前所在位置:珠峰网资料 >> 计算机 >> Oracle认证 >> 正文
oracle综合:JDBC调用PL/SQL函数(三)
发布时间:2010/11/17 9:50:04 来源:www.xue.net 编辑:城市总裁吧
   // 调用有一个out参数的函数; the function returns a VARCHAR

  cs = connection.prepareCall("{? = call get_age(?)}");

  // Register the types of the return value and OUT parameter

  cs.registerOutParameter(1, Types.VARCHAR);

  cs.registerOutParameter(2, Types.VARCHAR);

  // Execute and retrieve the returned values

  cs.execute();

  retValue = cs.getString(1);            // return value

  String outParam = cs.getString(2);    // OUT parameter

  // 调用有一个in/out参数的函数; the function returns a VARCHAR

  cs = connection.prepareCall("{? = call get_age(?)}");   // Register the types of the return value and OUT parameter

  cs.registerOutParameter(1, Types.NUMBER);

  cs.registerOutParameter(2, Types.NUMBER);

  1. cs = connection.prepareCall("{? = call get_age(?)}");

  2.     // Register the types of the return value and OUT parameter

  3.     cs.registerOutParameter(1, Types.NUMBER);

  4.     cs.registerOutParameter(2, Types.NUMBER);

  // Set the value for the IN/OUT parameter

  1. cs.setInt(2, 95002);

  2.

  3. // Execute and retrieve the returned values

  4. cs.execute();

  5. retValue = cs.getInt(1);            // return value

  6. outParam = cs.getInt(2);            // IN/OUT parameter

  7. } catch (SQLException e) {

  8. }

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved