Mailing List Archive



Back to the month index Back to the list index

Grant Totten (grantt@nortel.ca)
14 Nov 1997 07:52 EST


Message-Id: <199711141255.HAA08915@mocha.bunyip.com>
Date: 14 Nov 1997 07:52 EST
From: "Grant Totten" <grantt@nortel.ca>
Subject: [msqlperl] ordering rows

Hello all,

I've got a bit of a dilemma. Here is how I've defined
a table:

[grantt]> relshow comments

Database = sde
Table = comments

 +-----------------+----------+--------+----------+--------------+
 | Field | Type | Length | Not Null | Unique Index |
 +-----------------+----------+--------+----------+--------------+
 | updt | char | 14 | N | N/A |
 | comment | text | 132 | N | N/A |
 | comments_updt | index | N/A | N/A | N |
 +-----------------+----------+--------+----------+--------------+

The idea is that there can be multiple 'comment' rows per 'updt'.
For example:

[grantt_side]> sql "select * from comments where updt = 'grantt.240'"
mSQL >
Query OK. 7 row(s) modified or retrieved.

 +----------------+--------------------------------------------------------------------------------------------------------------------------------------+
 | updt | comment |
 +----------------+--------------------------------------------------------------------------------------------------------------------------------------+
 | grantt.240 | to support -t (time mode) and -b (build mode) |
 | grantt.240 | |
 | grantt.240 | a valid context. |
 | grantt.240 | Also disallowing a user to select a branch-point as |
 | grantt.240 | |
 | grantt.240 | active and the admin VOB is mounted. |
 | grantt.240 | as well as adding a check to see if the sdeadmin view is |
 +----------------+--------------------------------------------------------------------------------------------------------------------------------------+

So far, to get the rows to come out in the right order, I've
been using "order by _rowid". It's been working OK for a while.

But, that method of ordering doesn't necesarily work if you delete and
re-insert rows. It seems that the row IDs are re-used so you end up
with a semi-random ordering if you use _rowid.

So, what should I do to ensure I get the rows to come out in the
right order? Do I have to include a 'line number'? I've looked into
the _seq variable and it doesn't seem to be the right choice here.
Or is it?

Any recommendations?

Thanks in advance,

Grant Totten
Nortel Public Data Networks