Search code examples
postgresqltriggersrowplpgsqlaudit-logging

storing old values in audit trigger


Hi I'm developing simple audit trigger in postgres server. At the moment, I'm getting old value from name column such as below line.

v_old_data := ROW (OLD.name);

It works fine, but it store the value with parentheses. Such as '(john)'. Is there any way to storing/getting value from the table without parentheses?


Solution

  • Simply:

    v_old_data := OLD.name;
    

    You want the value, don't wrap it into a row and convert the whole row to text - including the parentheses that belong to the text representation of a row.