RE: Storing of Serial Number
Posted in 2005
Which manual will tell me more about sequences ? -----Original Message----- From: owner-informix-list@iiug.org [mailto:owner-informix-list@iiug.org] On Behalf Of Art S. Kagel Sent: 08 March 2005 12:52 AM To: informix-list@iiug.org Subject: Re: Storing of Serial Number nobody wrote: > > > Art S. Kagel wrote: > >> Andrew Hamm wrote: >> >> Well put Andrew. There is NO defensible<SP?> reason to peak at the >> next serial value in application code. The practice is a recipe for >> disaster. >> >> Art S. Kagel > > > Well sort of... > > Suppose you wanted to create an order entry where you knew the order > number at the start of the order... (And yes, there are reasons for > this...) Truly, but then SERIAL/SERIAL8 is not the answer for such an order number. > But then again, I wouldn't recommend a serial number, but possibly a > stored procedure or some code within the app to generate it. Like those > 6 - 8 character strings used by reservation systems as locator codes. > The sequences in IDS 9.4+ are ideal for this. And I've simulated that as you suggest in your other posting using a simple table with a single row that I SELECT next_id .... FOR UPDATE, UPDATE next_id = next_id + 1 ..., COMMIT to get the next order number. I think I'd use sequences for that now. Art S. Kagel sending to informix-list