pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Edipo Elder Fernandes de Melo <edipoelder@ig.com.br>
To: pgsql-sql@postgresql.org
Subject: Need help in how to....
Date: Thu, 26 Jul 2001 11:23:48 -0300
Message-ID: <200107261424.f6QEO8f45780@postgresql.org> (raw)

Hi,
 

 
    I doing a log to my DB. For this, I writing a trigger that inserts in a
 
log table the user, date, table changed and values changed.
 

 
    I was trying to do a generic procedure and use it on all tables, like 
this:
 

 
create function sp_log() returns opaque as '
 
declare
 
    v_type text;
 
    v_taable text;
 
    v_oid text;
 
    v_old text;
 
    v_new text;
 
begin
 
    v_type := tg_op;
 
    v_table := tg_relname;
 
    v_oid := tg_relid;
 
    -- v_old := old::text;
 
    -- v_new := new::text;
 
    insert into log (tablechanged, action, old_values, new_values, user)
 
        values (v_tabela, v_tipo, v_old, v_new, current_user);
 
    return new;
 
end;' language 'plpgsql';
 

 
    How I do to get the old and new values in a generic way (without use
 
coluns names or any else that bind a specific table)?
 

 
    Thanks for all help,
 

 
    Edipo Elder
 
    [edipoelder@ig.com.br]
 

_________________________________________________________
Oi! Você quer um iG-mail gratuito?
Então clique aqui: http://registro.ig.com.br/




Message-ID: <200107261424.f6QEO8f45780@postgresql.org>
Permalink:  ../200107261424.f6QEO8f45780@postgresql.org/
Also on:    postgresql.org/message-id/200107261424.f6QEO8f45780@postgresql.org

 · 

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: edipoelder@ig.com.br
  Subject: Re: Need help in how to....
  In-Reply-To: <200107261424.f6QEO8f45780@postgresql.org>

* 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