🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to INSERT IGNORE with Write Database operator....?

User: "tmyers"
New Altair Community Member
Updated by Jocelyn

Hi all. I'm using a Write Database operator to append rows to a MySQL table. I have a unique index consisting of 2 columns in the destination table. When my exampleset contains a row with a pair of values that already exists in the table, the Write Database errors and halts. I would like the operator to ignore such errors and continue to append all the rows where the pair of these values DON'T already exist in the table (i.e. to behave like a INSERT IGNORE statement). 

 

How can I run this operator so it would ignore such errors and only append "new" pairs of values?

 

Thanks in advance for any suggestions,

 

Tim

 

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "BalazsBaranyRM"
    New Altair Community Member
    Accepted Answer

    Hi,

     

    if you're fine with updating existing values (based on the unique index), you can use the Update Database operator. It will search for existing records (you need to select the two columns that contain the index values), insert the record if the key wasn't found, and update otherwise.

     

    If you really only want to insert new data, you could get the existing keys from the table (Read Database), do a Join with e. g. Left for identifying existing records, and just keep new records for the Write Database.

     

    Regards,

    Balázs