You should better use currval() instead select last_value from the sequence. Within the current session is currval() multiuser-resist.
Please read the documentation about sequences:
http://www.postgresql.org/docs/current/static/functions-sequence.html

Or use nextval() as suggested in the first comment.

Regards, Andreas