Current Query from Trigger

Started by Michael Forkalmost 22 years ago3 messagesgeneral
Jump to latest
#1Michael Fork
mfork00@yahoo.com

All,

I am trying to create a basic auditing mechanism using
triggers and would like to create a table that
contains the following information:

audit_operation = TG_OP
audit_username = CURRENT_USER
audit_time = CURRENT_TIMESTAMP
audit_table = TG_RELNAME
audit_key = NEW.key_field (or OLD.key_field)
audit_statement = ??????

How can I get the SQL statement that triggered the
trigger?

Thanks.

Michael

In reply to: Michael Fork (#1)
Escape chars

Dear Friends

Does postgresql api has some function similar to mysql_real_escape_string()
?

Regards
Luiz

#3CN
cnliou9@fastmail.fm
In reply to: Luiz Rafael Culik Guimaraes (#2)
Re: Escape chars

Does postgresql api has some function similar to
mysql_real_escape_string()
?

Manual 27.3.4 says that libpq has C function PQescapeString(). If that
function is not globally accessible, you might be able to build it from
its source code.

Regards,
CN