471,073 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Unique number/sequence

Hallo,

Hot to get unique, sequential number during execution
of stored procedure ?

I can create table with autoincrement column,
add record, get ident_current and delete record
each time i need the number.
However its not elegant i guess.
best regards
pluton

Jul 23 '05 #1
3 7677
See this thread for an example of using IDENTITY as a sequence
generator:

http://groups-beta.google.com/group/...c8639cd1a4924c

But remember that IDENTITY by itself is not guaranteed to be sequential
- if you really need sequential values with no gaps, then you'll have
to write your own code to do that. Requiring sequential numbers is
rather unusual, and could create performance problems - if you DELETE a
single row, you may have to UPDATE a large number of other rows to
maintain the sequence.

If this isn't helpful, you might want to give some more details of
exaclty what you need, especially why you need sequential numbers, and
what you want to happen when a row is DELETEd from the table.

Simon

Jul 23 '05 #2
> See this thread for an example of using IDENTITY as a sequence
generator:
Thanks a lot.
- if you really need sequential values with no gaps,
Gaps are accepted :)
If this isn't helpful
It is :) thanks :)
what you want to happen when a row is DELETEd from the table.


Just save space :)

Regards
pluton
Jul 23 '05 #3
>> I can create table with autoincrement column [sic], add record [sic] , get ident_current and delete record [sic] each time i need the number. However its not elegant i guess.<<

Rows are not records -- totally different concepts that separate an
RDBMS from file systems.

In RDBMS, there are sets and not sequences -- think sets and not
magnetic tapes. A key is a subset of attributes that make a row (not
a record!!) unique. The internal state of a counter when something was
inserted into PHYSICAL storage is not part of a LOGICAL data model.

The idea of a key is not that a machine invents them on the fly based
on the internal state of hardware; the idea is that they are a part of
the reality which you are modeling.

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Tony Clarke | last post: by
7 posts views Thread by hyppos | last post: by
6 posts views Thread by Poul Møller Hansen | last post: by
2 posts views Thread by pstachy | last post: by
9 posts views Thread by Robert Mago | last post: by
8 posts views Thread by Marc | last post: by
1 post views Thread by reachkaruna | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.