Feliz navidad y una consulta.

From: Gonzalo V <gvm2121(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Feliz navidad y una consulta.
Date: 2017-12-24 18:10:12
Message-ID: CAF40P_0tEutpgFjDNW8CoxJmH4a0db1XLc9unCJhvvfV+gGHrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Feliz navidad a todos!
Tengo una duda, si me pueden ayudar en esta navidad...
Necesito crear una funcion trigger que updatee unos datos a partir de otras
tablas pero no me funciona, alguien sale como se hace?. Lo que llevo hecho,
no me funciona.
De antemano, muchas gracias y feliz navidad y año nuevo.

CREATE OR REPLACE FUNCTION actualiza_fact_registro_trigger() RETURNS
TRIGGER AS $$
BEGIN
Update "Facturacion_registro" f set "Cod_sucursal"=(select s."ID" from
sucursales s where

s."DIRECCION"=f."Dirección")
from sucursales s
where s."RUT"=f."Rut"
and s."DIRECCION"=f."Dirección" and f."Cod_sucursal" is null;
RETURN new;
END
$$
LANGUAGE 'plpgsql';

CREATE TRIGGER vencimientos_trigger AFTER INSERT OR UPDATE ON
"Facturacion_registro" EXECUTE PROCEDURE actualiza_fact_registro_trigger();

Saludos,
Gonzalo

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Anthony Sotolongo 2017-12-24 18:32:22 Re: Feliz navidad y una consulta.
Previous Message motum hesa 2017-12-21 22:54:22 Re: Error con logical replication