0

I need to update multiple rows of a PLSQL table, something like this:

StringBuilder stringBuilder = new StringBuilder(
          "UPDATE review_item SET LAST_MODIFIED_TIMESTAMP = systimestamp, ")
          .append("target_urn = ?, ")
          .append("assignee_urn = NULL WHERE item_id in (")
          .append(StringUtils.join(itemIds, ","))
          .append(")");

      PreparedStatement ps = connection.prepareStatement(stringBuilder.toString());
      OracleUtil.bindInput(ps, 1, getRandomUuid(), dbClauses.getQueuePostCleanState());

Issue is - I need all the rows to get updated with a different random guid, in this case it is getting updated with the same one. Any way to do this?

  • Every row in Oracle has unique rowid (guid). Just copy rowid to your guid column. – Bartosz Olchowik Nov 16 '22 at 09:12
  • 1
    You are binding one GUID and applying to all item_ids. To get a unique GUID in your code, you would need to loop through each item_id and Prepare/Bind for each item_id. Another option might be [How to generate a GUID in Oracle?](https://stackoverflow.com/questions/3037462/how-to-generate-a-guid-in-oracle). – Jason Seek Well Nov 16 '22 at 21:06

0 Answers0