On the one hand, article table (code_of_bars, price_article), ticket (ticket_id, total_price) and finally the table that relates them formed (id_ticket, code_of_bars). I want that every time an entry is added in formed the price of the ticket is updated.
CREATE FUNCTION calcularPrecioTotal() RETURNS trigger AS '
BEGIN
new.ticket.precio_total:=old.ticket.precio_total + articulo.precio_articulo
from articulo inner join formado on articulo.codigo_de_barras=formado.codigo_de_barras;
return new;
END
' LANGUAGE plpgsql;
CREATE TRIGGER calcularPrecioTotal BEFORE INSERT or UPDATE
ON formado FOR each ROW
EXECUTE PROCEDURE calcularPrecioTotal();
This code gives me an error ERROR: el registro «old» no tiene un campo «ticket.preciototal»