     -- Populate the primer_working_plate_creation_process
     SELECT primer_set_id INTO wpp_emp_primer_set_id
         FROM qiita.primer_set
-        WHERE external_identifier = 'EMP primer set';
+        WHERE external_id = 'EMP primer set';
     INSERT INTO qiita.primer_working_plate_creation_process (process_id, primer_set_id, master_set_order_number)
         VALUES (wpp_process_id, wpp_emp_primer_set_id, 'EMP PRIMERS MSON 1')
         RETURNING primer_working_plate_creation_process_id INTO wpp_creation_process_id;

                        JOIN qiita.composition c USING (composition_id)
                        JOIN qiita.well w USING (container_id)
                        JOIN qiita.plate p USING (plate_id)
                    WHERE w.row_num = idx_row_well AND w.col_num = idx_col_well AND p.external_identifier = 'EMP primer plate ' || plate_idx;
                INSERT INTO qiita.primer_composition (composition_id, primer_set_composition_id)
                    VALUES (wpp_composition_id, psc_id);
            END LOOP;  -- Column loop
        END LOOP; -- Row loop
    END LOOP; -- Plate loop

    -- Add a 16S run
END $do$


DO $do$
DECLARE
    wpp_process_type_id         BIGINT;
    wpp_process_id              BIGINT;
    wpp_emp_primer_set_id       BIGINT;
    wpp_creation_process_id     BIGINT;
    wpp_plate_id                BIGINT;
    wpp_container_id            BIGINT;
    wpp_composition_id          BIGINT;
    plate_idx                   INT;
    idx_row_well                INT;
    idx_col_well                INT;
    well_container_type_id      BIGINT;
    primer_composition_type_id  BIGINT;
    microtiter_96_plate_type_id BIGINT;
    psc_id                      BIGINT;

    plating_process_id          BIGINT;
    plating_process_type_id     BIGINT;
    deepwell_96_plate_type_id   BIGINT;
    sample_plate_id             BIGINT;
    rec                         RECORD;
    plating_container_id        BIGINT;
    sample_composition_type_id  BIGINT;
    sample_type_id              BIGINT;
BEGIN
    --------------------------------------------
    -------- CREATE PRIMER WORKING PLATES ------
    --------------------------------------------
    SELECT process_type_id INTO wpp_process_type_id
        FROM qiita.process_type
        WHERE description = 'primer working plate creation';
