*This question has been revised.*

**Background:**

I have a list of fields (a view):

    FIELDS_W_DOMAINS_VW
    +-------------+------------+-------------+
    | TABLE_NAME  | FIELD_NAME | DOMAIN_NAME |
    +-------------+------------+-------------+
    | ENG.TABLE_1 | FIELD_1    | DOMAIN_ABC  |
    | ENG.TABLE_1 | FIELD_2    | DOMAIN_XYZ  |
    | ENG.TABLE_2 | FIELD_1    | DOMAIN_XYZ  |
    +-------------+------------+-------------+

The view looks at all the tables in a [geodatabase][1], and lists any fields that have a [domain][2] associated with them (a domain is the GIS equivelent of a lookup table/validation table).

The data tables look like this:

    TABLE_1
    +--------------+--------------+
    | FIELD_1      | FIELD_2      |
    | {DOMAIN_ABC} | {DOMAIN_XYZ} |
    +--------------+--------------+
    | A            | X            |
    | B            | Y            |
    | C            | zzzz         |
    | BLACK SHEEP  |              |
    +--------------+--------------+

    TABLE_2
    +--------------+--------------+
    | FIELD_1      | FIELD_2      |
    | {DOMAIN_XYZ} |              |
    +--------------+--------------+
    | Z            | ...          |
    | Y            |              |
    | X            |              |
    | asdf         |              |
    +--------------+--------------+

And the domains look like this:

    DOMAIN_VALUES_VW
    +------------+------+-------------+
    |   DOMAIN   | CODE | DESCRIPTION |
    +------------+------+-------------+
    | DOMAIN_ABC | A    | EH          |
    | DOMAIN_ABC | B    | BEE         |
    | DOMAIN_ABC | C    | SEE         |
    +------------+------+-------------+
    | DOMAIN_XYZ | X    | EX          |
    | DOMAIN_XYZ | Y    | WHY         |
    | DOMAIN_XYZ | Z    | ZEE         |
    +------------+------+-------------+

The source is a [xml column][3] in a single [system table][3]; I've [extracted][4] all the domains into this view.

**Question:**

For validation purposes, I have made a query that will check if there are values in a field that do not match the corresponding domain:

    INSERT INTO ENG.ERRORS_EVW
    (TABLE_NAME, FIELD_NAME, ERROR)
    SELECT
        'TABLE_1' AS TABLE_NAME
        ,'FIELD_1' AS FIELD_NAME
        ,FIELD_1 AS ERROR
    FROM 
        ENG.TABLE_1 
        LEFT JOIN ENG.DOMAIN_VALUES_VW 
        ON FIELD_1 = CODE
    WHERE 
        FIELD_1 IS NOT NULL
        AND CODE IS NULL

    +------------+------------+-------------+
    | TABLE_NAME | FIELD_NAME |   ERROR     |
    +------------+------------+-------------+
    | TABLE_1    | FIELD_1    | BLACK SHEEP |
    +------------+------------+-------------+

However, this query is hardcoded to be run on a single field, in a single table at a time. I need to check all of the fields with domains, in all of the tables in the database - programmatically.

I'm pretty sure this can be done with PL/SQL and dynamic SQL. I'm new to PL/SQL, and have been fighting with this for some time, but haven't come up with anything that remotely works.

I think the PL/SQL would need to:

 1. Loop through all rows in FIELDS_W_DOMAINS_VW. For each row, assign the table name, field name and domain name to variables.
 2. In each iteration of the loop, substitute the variables in place of the hardcoded table name, field name, and domain name in the query.
 3. Execute each dynamic query, which would input the values into an ERRORS table.
 
This sounds simple enough, but I'm so new to PL/SQL that it is beyond my grasp. 


  [1]: https://desktop.arcgis.com/en/arcmap/10.3/manage-data/gdb-architecture/the-geodatabase-is-object-relational.htm
  [2]: http://desktop.arcgis.com/en/arcmap/10.3/manage-data/gdbs-in-oracle/domain-storage-oracle.htm
  [3]: http://desktop.arcgis.com/en/arcmap/10.3/manage-data/using-sql-with-gdbs/overview-geodatabase-system-tables.htm
  [4]: http://gis.stackexchange.com/questions/215618/list-of-all-fields-and-their-domains-for-each-table-using-sql-table-name-fiel