SHARE
TWEET

Untitled

a guest Jul 15th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION FUN_AGREGAR_COPIAS()
  2. RETURNS TRIGGER AS $BODY$
  3. DECLARE
  4. --CODIGO_BARRA  TEXT := NEW."ISBN" || lpad(NEW."PAGINAS"::char ,6,'0');
  5. BEGIN
  6.     FOR i IN 1 .. NEW."COPIAS" LOOP
  7.         INSERT INTO public.libros("CODIGO_BARRA", "ID_EJEMPLAR", "PAGINAS")
  8.         VALUES(NEW."ISBN" || lpad(i::char ,3,'0'), NEW.ID, NEW."PAGINAS");
  9.     END LOOP;
  10. RETURN NEW;
  11. END $BODY$
  12. LANGUAGE PLPGSQL;
  13.  
  14. DROP TRIGGER IF EXISTS TR_AGREGAR_COPIA ON public."Ejemplar";
  15.  
  16. CREATE TRIGGER TR_AGREGAR_COPIA
  17. AFTER INSERT ON public."Ejemplar"
  18. FOR EACH ROW
  19. EXECUTE PROCEDURE FUN_AGREGAR_COPIAS();
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