Re: Trigger INSERT _ UPDATE

From: Miguel Ortega <mortega(at)tc(dot)com(dot)ve>
To: Dan <danstreet(at)gmail(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Trigger INSERT _ UPDATE
Date: 2006-12-13 16:23:18
Message-ID: 458028F6.5030902@tc.com.ve
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Yo intentaria con el Dollar-Quoting:

CREATE OR REPLACE FUNCTION "verifica_permisop" () RETURNS opaque AS $$
DECLARE
estado boolean;
numero integer;
BEGIN
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATED' THEN

SELECT status INTO estado FROM cierre WHERE anio=NEW.anio AND
mes= NEW.mes;

IF NOT found THEN --sino devuelve datos
return null;

ELSIF estado THEN --si esta cerrado ''t''
return null;

ELSE -- si esta abierto ''f''

SELECT max(nro) INTO numero FROM prueba WHERE anio=NEW.anio
AND mes=NEW.mes;
IF numero > 0 THEN
NEW.nro = numero + 1;
ELSE
NEW.nro = 1;
END IF;

RETURN NEW;
END IF;
END IF;

END;
$$ LANGUAGE 'plpgsql';

--
_________________________________________
Miguel A. Ortega B.
Analista de Sistemas y Soporte a Usuarios
Technologies Consulting C.A.

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Juan Martínez 2006-12-13 17:33:34 Re: date_style
Previous Message Dan 2006-12-13 16:09:09 Trigger INSERT _ UPDATE