1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| DECLARE
cur refcursor;
num_lot_fab "Production"."PR_Sortie_stock"."num_lot_fabrication"%TYPE;
code_article "Production"."PR_Ligne_fabrication"."code_article"%TYPE;
pcb "Production"."PR_Ligne_fabrication"."pcb"%TYPE;
nb_unite_fab "Production"."PR_Ligne_fabrication"."nb_unite_fabrique"%TYPE;
alveole "Production"."PR_Ligne_fabrication"."new_alveole"%TYPE;
BEGIN
UPDATE "Production"."PR_Stock_Courant" SET "nb_uc" = "nb_uc"-NEW."nb_uc"
WHERE "Numero_Lot" = NEW."num_lot_fabrication"
AND "Code_Alveole" = NEW."Code_Alveole"
AND "qte_uc"=New."poids_uc";
IF NEW."type_sortie_stock" = 1
THEN
BEGIN work;
OPEN cur FOR
SELECT "num_lot_fabrication"|| EXTRACT(DOY FROM now()),"PF_Articles"."Code_article","PR_Ligne_fabrication"."pcb", "PR_Ligne_fabrication"."nb_unite_fabrique", "PR_Ligne_fabrication"."new_alveole"
FROM "Production"."PR_Ligne_fabrication","ProduitsFinis"."PF_Articles"
WHERE "PR_Ligne_fabrication"."code_article"="PF_Articles"."Code_article"
AND "PR_Ligne_fabrication"."num_lot_fabrication"=NEW."num_lot_fabrication";
FETCH ALL IN cur; --INTO num_lot_fab,code_article,pcb,nb_unite_fab,alveole;
WHILE cur%FOUND
LOOP
INSERT INTO "ProduitsFinis"."PF_Entree_Stock"
("Numero_Lot","Code_Article", "nb_uc", "qte_uc","type_entree_stock","date_entree_stock","heure_entree_stock","Code_Alveole")
VALUES (num_lot_fab, code_Produit,nb_unite_fab, pcb,NEW."type_sortie_stock", now(), NOW(),alveole);
ind = ind + 1
END LOOP;
CLOSE cur;
COMMIT work;
END IF;
RETURN NEW;
END; |
Partager