By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,045 Members | 2,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,045 IT Pros & Developers. It's quick & easy.

Unique number/sequence

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
> 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

P: n/a
>> 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.