WITH UPSERT AS
  (UPDATE dlp.ST_ITEMSEAT ET
   SET (tick_server_id,
        itemseat_id,
        itemblock_id,
        itemzone_id,
        itemseat_row,
        itemseat_seat,
        itemseat_index,
        itemseat_value,
        itemseat_grid_x,
        itemseat_grid_y,
        itemseat_rect_x1,
        itemseat_rect_y1,
        itemseat_rect_x2,
        itemseat_rect_y2,
        itemseat_rect_x3,
        itemseat_rect_y3,
        itemseat_rect_x4,
        itemseat_rect_y4,
        itemseat_pos_x,
        itemseat_pos_y,
        itemseat_type,
        itemseat_cat,
        itemseat_color,
        entry_id,
        itemseat_status,
        lockcode_id,
        temp_itemzone_id,
        itemseat_row_label,
        itemseat_seat_label,
        etl_run_id) = (E.tick_server_id,
                       E.itemseat_id,
                       E.itemblock_id,
                       E.itemzone_id,
                       E.itemseat_row,
                       E.itemseat_seat,
                       E.itemseat_index,
                       E.itemseat_value,
                       E.itemseat_grid_x,
                       E.itemseat_grid_y,
                       E.itemseat_rect_x1,
                       E.itemseat_rect_y1,
                       E.itemseat_rect_x2,
                       E.itemseat_rect_y2,
                       E.itemseat_rect_x3,
                       E.itemseat_rect_y3,
                       E.itemseat_rect_x4,
                       E.itemseat_rect_y4,
                       E.itemseat_pos_x,
                       E.itemseat_pos_y,
                       E.itemseat_type,
                       E.itemseat_cat,
                       E.itemseat_color,
                       E.entry_id,
                       E.itemseat_status,
                       E.lockcode_id,
                       E.temp_itemzone_id,
                       E.itemseat_row_label,
                       E.itemseat_seat_label,
                       E.etl_run_id)
   FROM
     (SELECT *
      FROM loaddlp.ST_ITEMSEAT_INSERT
      WHERE LOADTABLETIME = '2016-03-21 14:53:28.771467' ) AS E
   WHERE et.tick_server_id = e.tick_server_id
     AND et.itemseat_id = e.itemseat_id returning ET.*)
INSERT INTO dlp.ST_ITEMSEAT
SELECT tick_server_id,
       itemseat_id,
       itemblock_id,
       itemzone_id,
       itemseat_row,
       itemseat_seat,
       itemseat_index,
       itemseat_value,
       itemseat_grid_x,
       itemseat_grid_y,
       itemseat_rect_x1,
       itemseat_rect_y1,
       itemseat_rect_x2,
       itemseat_rect_y2,
       itemseat_rect_x3,
       itemseat_rect_y3,
       itemseat_rect_x4,
       itemseat_rect_y4,
       itemseat_pos_x,
       itemseat_pos_y,
       itemseat_type,
       itemseat_cat,
       itemseat_color,
       entry_id,
       itemseat_status,
       lockcode_id,
       temp_itemzone_id,
       itemseat_row_label,
       itemseat_seat_label,
       etl_run_id
FROM
  (SELECT *
   FROM loaddlp.ST_ITEMSEAT_INSERT
   WHERE LOADTABLETIME = '2016-03-21 14:53:28.771467' ) AS ET
WHERE (et.tick_server_id,
       et.itemseat_id) NOT IN
    (SELECT tick_server_id,
            itemseat_id
     FROM upsert);
