 DELIMITER //
 CREATE PROCEDURE update_ecosystems()
 BEGIN
+SET @OLD_SQL_SAFE_UPDATES = (SELECT @@SQL_SAFE_UPDATES);
 SET SQL_SAFE_UPDATES = 0;
 UPDATE cpeEntry n INNER JOIN
     (SELECT DISTINCT vendor, product, MIN(ecosystem) eco

DELIMITER //
CREATE PROCEDURE cleanup_orphans()
BEGIN
SET SQL_SAFE_UPDATES = 0;
DELETE FROM cpeEntry WHERE id not in (SELECT CPEEntryId FROM software);
SET SQL_SAFE_UPDATES = 1;
END //
DELIMITER ;


  AND e.product = n.product 
SET n.ecosystem = e.eco
WHERE n.ecosystem IS NULL;
SET SQL_SAFE_UPDATES = @OLD_SQL_SAFE_UPDATES;
END //
DELIMITER ;

