[ic] Sessions in PostgreSQL

Doug Whiteley doug at scotwebshops.com
Tue Feb 12 05:50:36 EST 2008

This is just a heads-up for anyone in the same situation really.

I was looking at moving sessions into a postgresql database, and 
everything worked fine apart from the last_accessed column not being 
updated automatically. To get that working, you need to add a trigger, 
something like:

create trigger trigger_session_modification AFTER UPDATE ON session_data 
FOR EACH ROW EXECUTE PROCEDURE record_session_modification_trigger();

And just have the procedure do something along the lines of UPDATE 
session_data SET last_accessed=now() WHERE code=NEW.code;

You can just use a DEFAULT now() clause on your table definition to 
handle setting the last_Accessed on creation of a session.

One last thing: postgres handles timestamps differently to mysql, you 
don't need to use TIMESTAMP(14) for the column, you can just use an 
ordinary timestamp.

Douglas Whiteley, Web and Database Developer
Scotweb Marketing Ltd
Tel: 0131 510 0006 Fax: 0870 706 4938
doug at scotwebshops.com http://www.scotweb.co.uk

More information about the interchange-users mailing list