On 25-Jan-2004 Hassan Shaikh wrote: > Hi, > > I've a unique requirement where the transaction number should be > automatically generated (increment). I can't use AUTO_INCREMENT > column. The TRAN_NO is supposed to be in "YYYYMFFFFF" format, where: > > Field: TRAN_NO CHAR(10) > > M = Encoded current month (A: January, B: February, C: March . L: > December) > YYYY = Current year (e.g. 2004, 2005, ...) > FFFFF = Running serial number in hexadecimal format (so the smallest > number is 00001 and the largest number would be FFFFF; the serial > number will reset to 1 at the beginning of each month) > > How can I generate this number using MySQL without running into > concurrency problem? Also, this is a web-based app and I am planning > to use PHP for coding. My production environment is MySQL 4.0.17 on > Linux. Development platform is Windows XP with MySQL 4.0.17. >
CREATE TABLE stuff ( yr SMALLINT UNSIGNED, mn ENUM('A",'B', ... 'L"), seq INT UNSIGNED NOT NULL DEFAULT 0, ... PRIMARY KEY (yr,mn,seq) ); Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]