1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
PreparedStatement pstmt0 = connection.prepareStatement("select id1, id2 from T3 where ...?...");
PreparedStatement pstmt11 = connection.prepareStatement("insert into Arch_T1 select * from T1 where id1=?");
PreparedStatement pstmt12 = connection.prepareStatement("delete from T1 where id1=?");
PreparedStatement pstmt21 = connection.prepareStatement("insert into Arch_T2 select * from T2 where id2=?");
PreparedStatement pstmt22 = connection.prepareStatement("delete from T2 where id2=?");
PreparedStatement pstmt31 = connection.prepareStatement("insert into Arch_T3 values(?, ?)");
PreparedStatement pstmt32 = connection.prepareStatement("delete from T3 where id1=? and id2=?");
ResultSet rs1 = pstmt0.executeQuery();
pstmt0.set ??? <- en fonction de la clause where
while (rs1.next())
{
int id1 = rs1.getInt(1);
int id2 = rs1.getInt(2);
pstmt11.setInt(1, id1);
pstmt11.execute();
pstmt12.setInt(1, id1);
pstmt12.execute();
pstmt21.setInt(1, id2);
pstmt21.execute();
pstmt22.setInt(1, id2);
pstmt22.execute();
pstmt31.setInt(1, id1);
pstmt31.setInt(2, id2);
pstmt31.execute();
pstmt32.setInt(1, id1);
pstmt32.setInt(2, id2);
pstmt32.execute();
} |
Partager