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 35 36 37 38 39
   |  
// boucle sur tous mes ids
for(id : ids)
{
 
  // je récupère un nouvel valeur pour l'insertion dans une table
  String sql_query = "SELECT S_AC_TRACE_LINK.nextval FROM dual";
  String NEXT_VAL = executeSelectQuery(sql_query);
 
 
  // 1ère insertion dans une table
  sql_query = "INSERT INTO AC_TRACE_LINK (DAT_ID_IN, LINK_ID) VALUES (id, NEXT_VAL)"; // j'utilise le id de la boucle et le NEXT_VAL
  executeQuery(sql_query);
 
 
  // 2ème insertion dans une table
  sql_query = "INSERT INTO AC_TRACE_CONF (LINK_ID, CONTEXT_ID) VALUES (NEXT_VAL, 39)"; // j'utilise le NEXT_VAL
  executeQuery(sql_query);
}
 
// executeSelectQuery
public String executeSelectQuery(String sql_query)
{
   // je simplifie
   connection = getConnection();
   statement = connection.createStatement();
   rs = statement.executeQuery(sql_query);
 
   return value;
}
 
// executeQuery
public void executeQuery(String sql_query)
{
   // je simplifie
   connection = getConnection();
   statement = connection.createStatement();
   statement.executeUpdate(sql_query);
} | 
Partager