[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    [SQL] Need help in how to....
From:       Edipo Elder Fernandes de Melo <edipoelder () ig ! com ! br>
Date:       2001-07-26 14:23:48
[Download RAW message or body]

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/


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic