Y cual es la pregunta?



*-------------------------------------------------------*
*-Edwin Quijada
*-Developer DataBase
*-JQ Microsistemas
*-809-849-8087

* " Si deseas lograr cosas excepcionales debes de hacer cosas fuera de lo comun"
*-------------------------------------------------------*






________________________________
> Date: Mon, 26 Jan 2009 11:28:57 -0300
> Subject: [pgsql-es-ayuda] Buenos dias lista
> From: paulonu...@gmail.com
> To: pgsql-es-ayuda@postgresql.org
>
> Amigos:
> Soy nuevo en esta lista me gustaria si me pueden ayudar con el siguiente tema.
> tengo un trigger creado en Oracle y ahora estamos migrando a Postgresql, 
> bueno mi funcion disparadora es la siguiente
>
> CREATE OR REPLACE FUNCTION SUMA_INGRESO() RETURNS trigger AS $$
>
> BEGIN
> IF (TG_OP = 'INSERT') OR (TG_OP = 'UPDATE') THEN
> if new.CGINGRESO_VNETO != 0 then
> update cg_ingegre
> set CGINGEGRE_TINGRE = CGINGEGRE_TINGRE + new.CGINGRESO_VNETO
> where mgempre_cod = new.MGEMPRE_COD
>
> and CGPRODUCTOR_IDR = new.CGPRODUCTOR_IDR
> and CGFPROC_AAAA = new.CGFPROC_AAAA
> and CGFPROC_MM = new.CGFPROC_MM;
> end if;
> end if;
>
> IF (TG_OP = 'DELETE') OR (TG_OP = 'UPDATE') THEN
> if old.CGINGRESO_VNETO != 0 then
>
> update cg_ingegre
> set CGINGEGRE_TINGRE = CGINGEGRE_TINGRE - old.CGINGRESO_VNETO
> where mgempre_cod = old.MGEMPRE_COD
> and CGPRODUCTOR_IDR = old.CGPRODUCTOR_IDR
> and CGFPROC_AAAA = old.CGFPROC_AAAA
>
> and CGFPROC_MM = old.CGFPROC_MM;
> end if;
> end if;
> end;
> $$ LANGUAGE plpgsql;
>
> el trigger que lo llama es:
>
> CREATE TRIGGER "ICG_INGRESO"
> AFTER INSERT OR UPDATE OR DELETE
>
> ON cg_ingreso
> FOR EACH ROW
> EXECUTE PROCEDURE suma_ingreso();
>
> Este trigger no es mas que una suma ascendente.
> De antemano muchas gracias amigos
>
>

_________________________________________________________________
See how Windows® connects the people, information, and fun that are part of 
your life
http://clk.atdmt.com/MRT/go/119463819/direct/01/--
TIP 5: ¿Has leído nuestro extenso FAQ?
         http://www.postgresql.org/docs/faqs.FAQ.html

Responder a