Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE TRIGGER update_product_storage
- BEFORE UPDATE OF quantidade ON loja_produto
- FOR each ROW WHEN (NEW.quantidade > OLD.quantidade)
- DECLARE
- q NUMBER(6);
- BEGIN
- SELECT quantidade INTO q FROM produto WHERE cod_produto=:NEW.cod_produto;
- IF q < :NEW.quantidade - :OLD.quantidade THEN
- raise_application_error(-20003, 'Stock insuficiente em armaz¿);
- else
- update produto set quantidade=(q -(:NEW.quantidade - :OLD.quantidade)) where cod_produto=:NEW.cod_produto;
- end if;
- exception
- when NO_DATA_FOUND then
- raise_application_error(-20002, 'Produto inexistente em armaz¿..'); --supostamente este nunca dever¿ar...
- end;
- Error at line 12: PLS-00103: Encountered the symbol "PRODUTO" when expecting one of the following: ) , * & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset 0.05 seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement