Re: rowid no longer unique?
Posted in 1996
Mike Segel writes: * * Ron wrote: * > * > I think I remember seeing something in this bb about rowid no longer being * > necessarily unique within a table for v7. Is this true? More than once, * > while coding with ESQL, I coded a singleton select that I knew would return * > more than one row so I just added a where clause to avoid opening a cursor: * > * > select col from tab where rowid = * > (select max(rowid) from tab where key = "somevalue") * * Well, Not being a purist, I would consider a cursor. I too would consider this. * If you frag a table for pdq, rowid is not unique. This is not correct. If the table is frag'ed, there is no longer a ROWID field unless you "ALTER TABLE WITH ROWIDS". * IMHO, if you are going to write code, write it so that it is * maintainable. Rowid is no longer a *guaranteed* method of selecting a * single row. This might possibly be, but with our 2 million record test, both with unfrag'ed and frag'ed tables, ROWID stayed unique. * Now for $.02 worth, heres another tip from your uncle mike: * Use a cursor and have the select statement do an order by so that * your first row is the row you want. * * Declare the cursor. * Open the cursor. * fetch the row. * Close the cursor. * Go one with your program or Free the cursor. * * If this select statment is being used multiple times, it is better * to use a cursor. If this statement is being used in one part of the * program and is used infrequently, use a cursor since the overhead * is minimal. This, definitely, is the answer for the database that are not relational. By this, I mean, where tables are based on a unique key identifier to retrieve the data. Don't get me wrong, or software falls short of being truely relational. But, then again, whose doesn't? Thanks, ----------------------------------------------------------------------------- Robert Minter Data Systems Support Senior Software Engineer A Client Technologies Company E-Mail: rob@dssmktg.com Tel: 714.771.0454 Orange County Emmaus Community Fax: 714.771.3028 De Colores - Walk# OC-13 http://www.dssny.com