Field Values
The discounts and perks eligibility process sends data to suppliers. Not all of the data exists for all suppliers. In these cases, this table acts as an intermediary to avoid complex update statements and redundant clauses.
The program selects the appropriate field from a table using whatever complex SQL is required. It puts the value of the field into this table. The program then updates the target table with this table in a much simpler statement:
UPDATE target table
SET fieldname =
(SELECT A.FLD1
FROM PS_CO_FLD_VAL A
WHERE A.EMPLID = target table.EMPLID)
WHERE EMPLID IN
(SELECT EMPLID FROM PS_CO_FLD_VAL)
If we did not employ an intermediate, the two subselects cound be very complex as the statement first selects the records that has the source criteria and then repeats the complex logic in the WHERE clause subselect to limit the population being updated to just those employees who actually have data. |