int key = -1;
Connection conn = dataconn.getConnection();
CallableStatement cst = null;
String insertSql = "begin insert into OMS_ORDER values (SEQORDER.NEXTVAL) returning ORDER_ID into ?;end; ";
try {
conn.setAutoCommit(false);
cst = conn.prepareCall(insertSql); // 执行存储过程
cst.registerOutParameter(1, Types.INTEGER); // 为存储过程设定返回值
int count = cst.executeUpdate(); // 得到预编译语句更新记录或删除操作的结果
key = cst.getInt(1); // 得到返回值
} catch (SQLException e) {
System.out.println("插入失败");
e.printStackTrace();
}
java执行存储过程(Oracle)
最新推荐文章于 2022-10-24 18:42:37 发布