Académique Documents
Professionnel Documents
Culture Documents
statement_timeout = 0;
client_encoding = 'UTF8';
standard_conforming_strings = on;
check_function_bodies = false;
client_min_messages = warning;
--
_salario_anterior real;
_salario_nuevo real;
_salario_max real;
BEGIN
_salario_anterior = OLD.salario from empleado;
_salario_nuevo=NEW.salario from empleado;
_salario_max= _salario_anterior + (_salario_anterior *
0.5);
NEW;
END;
$$;
BEGIN
_id_empleado = id_emp from empleado;
_salario_anterior = OLD.salario from empleado;
_salario_nuevo=NEW.salario from empleado;
_nombre = nombre from empleado;
_apellido = apellido from empleado;
NEW.id_emp := id_emp from empleado ;
Insert into registro (id_empleado, salario_anterior,
salario_actual, nombre, apellido)
values (_id_empleado, _salario_anterior,_salario_nuevo,
_nombre, _apellido);
Return
NEW;
END;
$$;
id_responsable integer
);
);
--
Tablespace:
-ALTER TABLE ONLY bodega
ADD CONSTRAINT r1 PRIMARY KEY (id);
statement_timeout = 0;
client_encoding = 'UTF8';
standard_conforming_strings = on;
check_function_bodies = false;
client_min_messages = warning;
_idfactura integer;
_idproducto integer;
_cantidad integer;
_vu real;
_vt real;
_vi real;
_ip text;
_hora time;
_fecha date;
BEGIN
_ip=inet_client_addr();
_hora= current_time;
_fecha= current_date;
IF (TG_OP='INSERT' or TG_OP='UPDATE') then
_idfactura= NEW.id_factura;
_idproducto= NEW.id_producto;
_cantidad= NEW.cantidad;
_vu= NEW.valor_unitario;
_vt= NEW.valor_total;
_vi= NEW.valor_iva;
insert into
audi_detalle(idfactura,idproducto,cantidadp,valorunitario,valortot
al,valoriva,accion,ip,hora,fecha_actual)
values
(_idfactura,_idproducto,_cantidad,_vu,_vt,_vi,TG_OP,_ip,_hora,_fec
ha);
ELSE IF (TG_OP='DELETE') then
insert into
audi_detalle(idfactura,idproducto,cantidadp,valorunitario,valortot
al,valoriva,accion,ip,hora,fecha_actual)
values
(OLD.id_factura,OLD.id_producto,OLD.cantidad,OLD.valor_unitario,OL
D.valor_total,OLD.valor_iva,TG_OP,_ip,_hora,_fecha);
End IF;
End IF;
Return
OLD;
END;
$$;
_numero integer;
_fecha date;
_idc integer;
_idv integer;
_vt real;
_vti real;
_hora time;
_ip text;
BEGIN
_hora= current_time;
_ip=inet_client_addr();
IF (TG_OP='INSERT' or TG_OP='UPDATE') then
_numero= NEW.numero_factura;
_fecha= NEW.fecha;
_idc= NEW.id_cliente;
_idv= NEW.id_vendedor;
_vt= NEW.valor_total;
_vti= NEW.valor_total_iva;
insert into
auditoria_fventa(numerofactura,fecha_accion,idcliente,idvendedor,v
alortotal,valortotal_iva,hora,accion,ip)
values
(_numero,_fecha,_idc,_idv,_vt,_vti,_hora,TG_OP,_ip);
ELSE IF (TG_OP='DELETE') then
insert into
auditoria_fventa(numerofactura,fecha_accion,idcliente,idvendedor,v
alortotal,valortotal_iva,hora,accion,ip)
values
(OLD.numero_factura,OLD.fecha,OLD.id_cliente,OLD.id_vendedor,OLD.v
alor_total,OLD.valor_total_iva,_hora,TG_OP,_ip);
End IF;
End IF;
Return
OLD;
END;
$$;
_cant real;
_inv real;
_ncant real;
_id INTEGER;
BEGIN
_cant= NEW.cantidad;
IF (_cant <=100) then
_id= NEW.id_producto;
_inv= cantidad from inventario WHERE id_producto= _id ;
_ncant= _inv - _cant;
update inventario set cantidad = _ncant where
id_producto=_id;
update producto set existencias = _ncant WHERE id=_id;
ELSE
RAISE EXCEPTION 'Cantidad
END IF;
Incorrecta';
Return
OLD;
END;
$$;
);
--
201
201
201
\.
2013-03-20 51908701
2
INSERT
::1
2013-03-20 51908701
4
DELETE
::1
2013-03-20 51908701
5
INSERT
::1
91221 5220000
720000
18:53:53.106
91221 5220000
720000
19:01:35.269
91221 5220000
720000
19:01:55.907
id_cliente,
FROM stdin;
144000
720000