     -- 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;

    FOR plate_idx IN 1..8 LOOP
        -- The working primer plates are identifier by the template plate number and the
        -- date they're created. Ther are 96-well microtiter plates
        INSERT INTO qiita.plate (external_identifier, plate_configuration_id, discarded)
            VALUES ('EMP Primer plate ' || plate_idx::varchar || ' 10/23/2017', microtiter_96_plate_type_id, false)
            RETURNING plate_id INTO wpp_plate_id;



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';
