Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Generating unique session ids



"Antimon" <antimon(at)gmail(dot)com> writes:
> As the id field is primary key, it should generate a unique violation
> if duplicate ids created, might be seen rarely but wanted to solve it
> anyway.

Why don't you just use a serial generator?

 So i decided to check it by changing "sid := md5(random());" to
> "sid := extract(minute from now());" When i run it, returns the minute
> as session key and inserts an entryy for it, but if i call it again in
> the same minute, it never ends execution. I expected it to return the
> minute when system clock minute changes but it runs forever.

Yup, see
http://www.postgresql.org/docs/8.1/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group