title: Using Oracle sequence to insert log id into 2 tables from jdbc?
body: <p>I am using oracle sequence for inserting log id into tableA as follows,</p>
  
  <pre><code>String SQL_PREP_INSERT = "INSERT INTO tableA (LOG_ID,USER_ID,EXEC_TIME) VALUES"
              + " (logid_seq.nextval, ?, ?)";
  </code></pre>
  
  <p>Then getting the recently inserted value,</p>
  
  <pre><code>String SQL_PREP_SEL = "SELECT max(LOG_ID) FROM tableA ";
  
  stmt = con.prepareStatement(SQL_PREP_SEL);
  stmt.execute();
  ResultSet rs = stmt.getResultSet();
  if (rs.next()) {
  logid = rs.getInt(1);
  }
  </code></pre>
  
  <p>And inserting it into tableB,</p>
  
  <pre><code>String SQL_PREP_INSERT_DETAIL = "INSERT INTO tableB (LOG_ID, RESPONSE_CODE, RESPONSE_MSG) VALUES"
                  + " (?, ?)";
  
          stmt = con.prepareStatement(SQL_PREP_INSERT_DETAIL);
          stmt.setInt(1, logid);
          stmt.setString(2, respCode);
          stmt.setString(3, respMsg);
          stmt.execute();
  </code></pre>
  
  <p>Is there a way to generate sequence in Java instead of Oracle and insert into both tables at once, instead of selecting from tableA and inserting into tableB?</p>