"Frank Millman" <frank(at)chagford(dot)com> writes:
> uom := (select uom from prodclass where code = prod_class) ;
^^^ ^^^
It's a bad idea to use plpgsql variable names that match fields of your
tables. In this case, since the variable uom starts out NULL, the
select effectively reads "(select NULL from ...)".
regards, tom lane