Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Duplicate Entry

    Hello,

    I am working with mySQL and want the ability to add data without having to validate if the data already exists.
    mySQL has
    Code:
     INSERT IGNORE
    . Can I use this on the server side?

    here is my current add DSResponse code

    type1ID and type2ID both are primary keys
    Code:
    for (final long type1ID : type1IDs) {
       final Map<String, Object> object = new HashMap<>();
       object.put("type1ID", type1ID);
       for (final Long type2ID : type2IDs) {
          object.put("type2ID", type2ID);
          new DSRequest("typeTable", DataSource.OP_ADD, rpcManager).setValues(object).execute()
       }
    }

    #2
    You can do this via the <customSQL> tag but writing the INERT IGNORE part yourself and then using the $defaultValuesClause template variable.

    Comment


      #3
      Perfect! Thanks so much.

      Here is all I needed.

      Code:
      <operationBinding operationType="custom" operationId="addAllTypes">
         <customSQL> INSERT IGNORE INTO type_table $defaultValuesClause </customSQL>
      </operationBinding>

      Comment

      Working...
      X