Re: Reversal of Records
Posted in 1991
John Baker writes: >How do I get the standard engine to use an ORDER BY clause >(on a serial field) when it goes out to retrieve records >during a "Query" done while running an INFORMIX-SQL >PERFORM screen? > A perform screen will retrieve rows ordered on a particular field under these circumstances: 1. The field has an index on it 2. A restriction, even a trivial one, is placed on that field before the query is executed To apply this to the serial number: 1. Place a unique index on the SERIAL column. 2. Instruct the user to place the following restriction in the SERIAL field on the perform screen prior to executing the query: >0 This will include all rows, but will cause perform to use the index, and present the rows ordered on the index. If your requirement is that this must be transparent to the user, then PERFORM is the wrong tool - it's a straightforward tradeoff between flexibility and simplicity between a 4GL screen and perform screen. > Quoting Greg Bryan, DHL WORLDWIDE EXPRESS (gbryan@ssf-sys.dhl.com): > > > [ text deleted ] > > The reason for this is the reason that SERIAL exists - it provides > > an automatically generated primary key. The only implied > > requirements are that a type SERIAL be UNIQUE and NOT NULL. > > In addition, a quick review of several Informix 4.0 manuals > > indicates that there is no promise made there about ordering > > of type SERIAL with respect to INSERT sequence. > > [ text deleted ] > > Greg, please tell us which pages of the 4GL manuals discuss "ordering of type > SERIAL with respect to INSERT sequence." I can't find anything. > Sorry if I wasn't clear here - what I am saying is that I can't find anything either. If Informix doesn't make the promise, they won't feel obligated to keep it (exactly as in the case of ROWID). I am also not suggesting that they should make such a promise - there is no reason for type SERIAL to reflect the order of entry, or any other order - it only needs to be unique and not null, based upon the requirement that it fulfills (ie. the requirement for a synthetic primary key). ------------ DHL WORLDWIDE EXPRESS ------------------------------------------- Greg Bryan gbryan@ssf-sys.dhl.com DHL Systems Data Administrator uunet!ssf-sys.dhl.com!gbryan San Francisco -------------------------------------------------------------------------------