in reply to SQL unique IDs and Sessions (was: yesterday I posted this and you all aksed for more info so ........)

Just like I thought, session_id is a varchar. Varchars alphabetize like this:
0
1
10
11
2
3
4
5
6
7
8
9
So 9 is the max, which isn't what you want. Make session_id a number, or make sure you always zero-pad it, or initialize it to "aaaaaaaaaa", or something.

Update: Don't know if it's possible two copies of this script could run at the same time, but you might have a problem with two different sessions creating the same new session id at once. Might be better for you to do something like:

insert into sessions (session_id, session_date) select max(session_id)+1, ? from sessions
... or anything else that does proper locking.
  • Comment on Re: yesterday I posted this and you all aksed for more info so ........
  • Download Code

Replies are listed 'Best First'.
(crazyinsomniac: bad advice) Re:^2 yesterday I posted this and you all aksed for more info so ........
by crazyinsomniac (Prior) on May 11, 2001 at 13:26 UTC
Re: Re: yesterday I posted this and you all aksed for more info so ........
by esolm (Acolyte) on May 10, 2001 at 22:47 UTC
    Thanks, changed them to decimal. Works like a charm