[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ic] Sessions in PostgreSQL


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
suppressed http://www.scotweb.co.uk

_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.