Advertisement
Guest User

Untitled

a guest
May 24th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.97 KB | None | 0 0
  1. CREATE OR REPLACE TRIGGER update_product_storage
  2.   BEFORE UPDATE OF quantidade ON loja_produto
  3.   FOR each ROW WHEN (NEW.quantidade > OLD.quantidade)
  4.   DECLARE
  5.     q NUMBER(6);
  6.   BEGIN
  7.     SELECT quantidade INTO q FROM produto WHERE cod_produto=:NEW.cod_produto;
  8.     IF q < :NEW.quantidade - :OLD.quantidade THEN
  9.       raise_application_error(-20003, 'Stock insuficiente em armaz¿);
  10.    else
  11.      update produto set quantidade=(q -(:NEW.quantidade - :OLD.quantidade)) where cod_produto=:NEW.cod_produto;
  12.    end if;
  13.  exception
  14.    when NO_DATA_FOUND then
  15.      raise_application_error(-20002, 'Produto inexistente em armaz¿..'); --supostamente este nunca dever¿ar...
  16.  end;
  17.  
  18. 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