SHARE
TWEET

Untitled

a guest Jun 25th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP TRIGGER ActualizarBono;
  2. CREATE OR REPLACE TRIGGER ActualizarBono
  3. AFTER UPDATE OR INSERT OR DELETE ON MEDICAMENTOS
  4. FOR EACH ROW
  5. BEGIN
  6.     UPDATE fichapac_detalle SET bonofarma = (SELECT B.BONO FROM MEDICAMENTOS A JOIN REMEDIO B ON(A.ID_REM = B.ID_REM));
  7. END;
  8. /
  9.  
  10. INSERT INTO MEDICAMENTOS VALUES(50,6,'uno al día x 15 días');
  11. INSERT INTO MEDICAMENTOS VALUES(50,7,'3 veces a la semana');
  12. SELECT B.BONO FROM MEDICAMENTOS A JOIN REMEDIO B ON(A.ID_REM = B.ID_REM);
  13. create or replace trigger TR_BONO_FARMA
  14.     after insert or update on MEDICAMENTOS
  15.     for each row
  16. Begin
  17.     IF (INSERTING) THEN
  18.         UPDATE fichapac_detalle
  19.         SET bonofarma = round((SELECT B.BONO FROM MEDICAMENTOS A JOIN REMEDIO B ON(A.ID_REM = B.ID_REM)));
  20.     elsif (UPDATING) THEN
  21.         UPDATE fichapac_detalle
  22.         SET bonofarma = round((SELECT B.BONO FROM MEDICAMENTOS A JOIN REMEDIO B ON(A.ID_REM = B.ID_REM))))
  23.         WHERE NUMERO = :NEW.NUMERO;
  24.     end if;
  25. end TR_BONO_FARMA;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top