Options

"Insert and Update a Database"

DayoMDayoM Member Posts: 1 Contributor I
edited June 2019 in Help
Hi all,

Forgive me if this is a simple question. I am reading data from a csv file which matches a database table. The primary key of the db is composed of several fields. So far I have not had to much luck with inserting or updating because I get primary key violations. When you setup the file can you setup multiple id's that Match the db?
Tagged:

Answers

  • Options
    Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    Hi,

    you can use the update database operator and set the attribute filter type to subset. Then you have to select the attributes your primary key consists of.

    Here is an example:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.3.000" expanded="true" name="Process">
        <process expanded="true" height="190" width="413">
          <operator activated="true" class="retrieve" compatibility="5.3.000" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <operator activated="true" class="update_database" compatibility="5.3.000" expanded="true" height="60" name="Update Database" width="90" x="246" y="30">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attributes" value="|a1|a2"/>
          </operator>
          <connect from_op="Retrieve" from_port="output" to_op="Update Database" to_port="input"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
        </process>
      </operator>
    </process>
    Best,
    Nils
Sign In or Register to comment.