2010/12/4 Mathieu De Zutter <mathieu@xxxxxxxxxxxx>
INSERT INTO log_event (user_id, ip, action_id, object1_id, object2_id,
For each page load I first create an entry in that table, e.g.:
INSERT INTO log_event (user_id, ip, action_id, object1_id, object2_id,
event_timestamp, comments) VALUES (1, '127.0.0.1', 96, null, null,
NOW(), 'TEST');
After that, I want to retrieve the data stored in log_event from a
trigger, e.g.:
SELECT user_id FROM log_event WHERE id = CURRVAL('log_event_id_seq');
This way my insert-trigger knows who is creating the new row, while
using only one pg-user to query the database.
Please note that you can use next query to perform both insert and select:
event_timestamp, comments) VALUES (1, '127.0.0.1', 96, null, null,
NOW(), 'TEST') returning user_id;
--
Best regards,
Vitalii Tymchyshyn