pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maurício Sessue Otta <mauricio@cristorei.com.br>
To: LISTA POSTGRES <pgsql-sql@postgresql.org>
Subject: Trigger para fazer log
Date: Thu, 6 Feb 2003 10:06:32 -0200
Message-ID: <002301c2cdd8$30b82640$830101c0@mauricio1> (raw)

Oi lista,

tenho um trigger que deve validar alguns campos para entrada/saida de funcionarios e que deve fazer um "log"
do que vai acontecendo.

Por exemplo:
quando é o início do expediente, o trigger deverá guardar algo assim no "log":
Cadastro da Entrada-1: Data 2003-02-06  Horário: 09:51:00

Se o funcionario tentar burlar o esquema e tentar inserir/atualizar o registro, o trigger deve guardar na tabela log que 
foi feita essa tentativa e retornar um erro para o meu script PHP.

Meu problema:
no fim do trigger tenho o seguinte:
 IF length(m_erro) = 0 THEN
 ELSE
  RAISE EXCEPTION ''%'', m_erro;
 END IF;
 RETURN null;

Quando está "EXCEPTION", o que deveria ser guardado no "log" também é desfeito. Quando coloco "NOTICE", a
informação vai para o LOG.

Como fazer para o trigger gerar uma "EXCEPTION" e mesmo assim gravar em outra tabela?!?!


[]'s Mauricio

view thread (3+ messages)  latest in thread

Message-ID: <002301c2cdd8$30b82640$830101c0@mauricio1>
Permalink:  ../002301c2cdd8$30b82640$830101c0@mauricio1/
Also on:    postgresql.org/message-id/002301c2cdd8$30b82640$830101c0@mauricio1

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mauricio@cristorei.com.br
  Subject: Re: Trigger para fazer log
  In-Reply-To: <002301c2cdd8$30b82640$830101c0@mauricio1>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox