I have a batch insert where I would need to check for some columns conditionally and do either insert or update. Right now I am doing this by checking a conflict on one column:
const val sql = """
INSERT INTO customer (name, customer_code, org_number, address, zip_code, zip_area, country_code, created_by, updated_by, subcustomer, credit_blocked, uuid, is_deleted)
values (...values)
on conflict (uuid) do update
set
I have records in the customer table that don't have the value for the uuid field. In that case I should check if the name and subcustomer match and do the update. So in pseudo code something like this:
IF (uuid == values.uuid)
do updated
ELSE IF (name == values.name AND subcustomer == values.subcustomer)
do updated
ELSE do insert
I am not sure how to do that with batch inserts?