最简单的Java调用Orcale存储过程进行批量操作

首先在orcale数据库中定义一个存储过程<batchUpdateXX()>:
create or replace procedure batchUpdateXX(p_age in number) as
begin
    update XX set AGE=AGE+1 where AGE>p_age;
end;


java调用代码:

    tx = session.beginTransaction();
    Connection con = session.getSession();
    String procedure = "{call batchUpdateXX(?)}";
    CallableStatement cstmt = con.prepareCall(procedure);
    cstmt.setInt(1,0);
    cstmt.executeUpdate();
    tx.commit();


你可能感兴趣的:(java)