Isn't there a chance that you could get a ID that is the same as one 
already in use? and if this happens what happens on the insert?


Wishing you the best you know you deserve,

______________________
Lucas Heuman
Web Developer
Ricomm Systems Inc. 
FAA, WJHTC/Bldg 300, 3nd Fl., L33
Atlantic City Int'l Airport, NJ  08405
Phone 609.485.5401



"Olexandr Melnyk" <[EMAIL PROTECTED]> 
08/07/2007 08:19 AM

To
mysql@lists.mysql.com
cc

Subject
Fwd: auto increment format






You can do that using a "before insert" trigger, something like (untested) 
:

CREATE TRIGGER test1bi
BEFORE INSERT ON test1
  FOR EACH ROW BEGIN
    NEW.ID = COALESCE( NEW.ID, SHA1(CAST(RAND() AS CHAR)))
  END;


2007/8/7, shivendra <[EMAIL PROTECTED]>:
>
>
> Hi, I'm looking for some basic help. I am developing a MySQL database 
and
> want to auto increment a field, but I don't want it to just count 1,2,3,
> etc. I want the field to be a combination of letters and numbers, at 
least
> 8
> digits long, completely random for security porposes, but do this
> automatically, everytime a record is added. For example, ord5001, 
ord5002,
> ord5003, etc. Does anyone know how to do this in MySQL?
> --
> View this message in context:
> http://www.nabble.com/auto-increment-format-tf4229677.html#a12032917
> Sent from the MySQL - General mailing list archive at Nabble.com.
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:     http://lists.mysql.com/[EMAIL PROTECTED]
>
>


-- 
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/

Reply via email to