Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. CREATE OR REPLACE FUNCTION public.add_rec_inventario()
  2. RETURNS trigger
  3. LANGUAGE plpgsql
  4. AS $function$
  5. begin
  6. -- table_schema: id_movto | id_cedis | id_tipo_movto | id_producto | folio_movto | lote | cantidad_entrada | cantidad_salida | id_usuario | fecha_add
  7. --
  8. insert into inventario (id_cedis, id_tipo_movto, id_producto, folio_movto, lote, cantidad_entrada, cantidad_salida, id_usuario, fecha_add) values (NEW.id_cedis, 1, NEW.id_producto, NEW.id_recepcion, NEW.lote, NEW.cantidad, 0, NEW.id_usuario, current_timestamp);
  9. exception when others then
  10. -- log if fails;
  11. insert into function_logs(message,fecha_add) values('ERR: add_rec_inventario ' || SQLERRM, current_timestamp);
  12.  
  13. return NEW;
  14. end;
  15. $function$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement