PERFORM deleteBOMWorkset(_bomworksetid);
+ -- Create bomhead record if one does not exist
+
+ SELECT bomhead_id INTO _bomheadid
+ FROM bomhead
+ WHERE (bomhead_item_id=NEW.bomitem_parent_item_id);
+
+ IF (NOT FOUND) THEN
+ INSERT INTO bomhead (bomhead_item_id, bomhead_batchsize, bomhead_rev_id)
+ VALUES (NEW.bomitem_parent_item_id, 1, -1);
+ END IF;
+
-- Set defaults
NEW.bomitem_rev_id := COALESCE(NEW.bomitem_rev_id, -1);
NEW.bomitem_booitem_seq_id := COALESCE(NEW.bomitem_booitem_seq_id, -1);