1 2 3 4 5 6 7 8 9
|
IF (SELECT parts.part_id FROM parts WHERE part_nm = 'test' OR part_nm = 'test **NO STOCK**') = NULL THEN:
INSERT INTO parts (part_nm, part_snm, part_category_id, maker_id, maker_ref, unit_id, stock_min, stock_max, is_certificate_needed, is_orderable, comments,drawing_ref) VALUES ('test', 'test', 2, 3981, 'test', 6, 0,9999, 'f', 't', 'test','');
INSERT INTO catalog_parts (catalog_id, part_id, catalog_parts_reference, catalog_parts_price, catalog_parts_currency_cd, catalog_parts_activated) VALUES ((SELECT catalog_id FROM catalog WHERE catalog_name = 'test'), (SELECT last_value FROM parts_part_id_seq), 'test', 50, 'EUR', 't');
INSERT INTO parts_on_equipments (part_id, equipment_id) VALUES ((SELECT last_value FROM parts_part_id_seq), 1704);
ELSE:
UPDATE catalog_parts SET catalog_parts_price = '50' WHERE catalog_id = (SELECT catalog_id FROM catalog WHERE catalog_name = 'test') AND part_id IN (SELECT part_id FROM parts WHERE part_nm = 'test' OR part_nm = 'test **NO STOCK**');
UPDATE parts SET unit_id = 6 WHERE part_nm = 'test' OR part_nm = 'test **NO STOCK**';
END; |
Partager