dbTalk Databases Forums  

reset a sequence in a trigger

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss reset a sequence in a trigger in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Ed Prochak
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-20-2005 , 12:47 AM






Werner Hofmann wrote:

Quote:
Stupid question maybe but why reset it? A sequence is a large number.
Are you try to save numbers? You can set a max value and then cycle
it. Resetting a sequence just seems like you're going about solving
the wrong problem.

Thanks,

Lewis



In this table I have a lot of transactions, and it can be, that the ID which
is the primary key can overrun after some time (some years). I can not use
another primary key, because this would be with a VARCHAR2 column. And so I
wantet to be save, that the oldest entry have the smallest ID for sorting.

Werner
Then why do't you include a updated_when column on the table? Then sort
according to the time it was updated rather than tricking around with pseudo-keys.



--
Ed Prochak
running http://www.faqs.org/faqs/running-faq/
netiquette http://www.psg.com/emily.html
--
"Two roads diverged in a wood and I
I took the one less travelled by
and that has made all the difference."
robert frost



Reply With Quote
  #12  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-20-2005 , 10:18 AM






Werner Hofmann wrote:
Quote:
In this table I have a lot of transactions, and it can be, that the ID which
is the primary key can overrun after some time (some years). I can not use
another primary key, because this would be with a VARCHAR2 column. And so I
wantet to be save, that the oldest entry have the smallest ID for sorting.
Let's do the math:
Let's take a number (actually, number(38,*)) as ID column.

Largest number to be recorded would be 10^39 - 1 (38 nines)
Suppose you machine does "a lot of transactions": 1 million per day.
365 days a year, year-in, year-out.
That's 365,000,000 transactions a year.
that will take you 10^38/3.65*10^8, ehhhmmm about 3*10^30 years
to fill up your sequence.

By that time, the sun has grown so large, the earth is no more.

If you don't like the example, take a gazillion-way cluster, and
chew away 1 billion transactions (1000 times as much)
per second (86400 times as much). No way you are going
to fill up your sequence (well, about 86 million times as fast)
in your liftime.

Unless I'm mistaken (and my math isn't what it used to be): bullocks!

--
Regards,
Frank van Bortel


Reply With Quote
  #13  
Old   
Paul
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-20-2005 , 11:32 AM





Frank van Bortel <frank.van.bortel (AT) gmail (DOT) com> wrote:


Quote:
Unless I'm mistaken (and my math isn't what it used to be): bullocks!
That's bollocks (or the Dublin variation bollix).



Paul...



--

plinehan __at__ yahoo __dot__ __com__

XP Pro, SP 2,

Oracle, 9.2.0.1.0 (Enterprise Ed.)
Interbase 6.0.2.0;

When asking database related questions, please give other posters
some clues, like operating system, version of db being used and DDL.
The exact text and/or number of error messages is useful (!= "it didn't work!").
Thanks.

Furthermore, As a courtesy to those who spend
time analyzing and attempting to help, please
do not top post.


Reply With Quote
  #14  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-20-2005 , 02:36 PM



Paul wrote:
Quote:
Frank van Bortel <frank.van.bortel (AT) gmail (DOT) com> wrote:



Unless I'm mistaken (and my math isn't what it used to be): bullocks!


That's bollocks (or the Dublin variation bollix).

<g> - thankx. Would Someone rather have maths instead of math?!?
--
Regards,
Frank van Bortel


Reply With Quote
  #15  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-21-2005 , 03:07 AM



Frank van Bortel wrote:
Quote:
Werner Hofmann wrote:

In this table I have a lot of transactions, and it can be, that the ID which
is the primary key can overrun after some time (some years). I can not use
another primary key, because this would be with a VARCHAR2 column. And so I
wantet to be save, that the oldest entry have the smallest ID for sorting.


Let's do the math:
Let's take a number (actually, number(38,*)) as ID column.

Largest number to be recorded would be 10^39 - 1 (38 nines)
Suppose you machine does "a lot of transactions": 1 million per day.
365 days a year, year-in, year-out.
That's 365,000,000 transactions a year.
that will take you 10^38/3.65*10^8, ehhhmmm about 3*10^30 years
to fill up your sequence.

By that time, the sun has grown so large, the earth is no more.

If you don't like the example, take a gazillion-way cluster, and
chew away 1 billion transactions (1000 times as much)
per second (86400 times as much). No way you are going
to fill up your sequence (well, about 86 million times as fast)
in your liftime.

Unless I'm mistaken (and my math isn't what it used to be): bullocks!

Hm - nobody noticed the error in the numbers?
The Number datatype can store numbers with magnitudes between
1*10^-130 and 9.99...9*10^125 (38 nines, followed by 88 zeros),
with *38 digits of precision*.

So, actually, I was about a factor 10^88 off - minor detail, as
the earth still ceased to exist

--
Regards,
Frank van Bortel


Reply With Quote
  #16  
Old   
Mark C. Stock
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-21-2005 , 05:23 AM




"Frank van Bortel" <frank.van.bortel (AT) gmail (DOT) com> wrote

Quote:
Frank van Bortel wrote:
Werner Hofmann wrote:

In this table I have a lot of transactions, and it can be, that the ID
which
is the primary key can overrun after some time (some years). I can not
use
another primary key, because this would be with a VARCHAR2 column. And so
I
wantet to be save, that the oldest entry have the smallest ID for
sorting.


Let's do the math:
Let's take a number (actually, number(38,*)) as ID column.

Largest number to be recorded would be 10^39 - 1 (38 nines)
Suppose you machine does "a lot of transactions": 1 million per day.
365 days a year, year-in, year-out.
That's 365,000,000 transactions a year.
that will take you 10^38/3.65*10^8, ehhhmmm about 3*10^30 years
to fill up your sequence.

By that time, the sun has grown so large, the earth is no more.

If you don't like the example, take a gazillion-way cluster, and
chew away 1 billion transactions (1000 times as much)
per second (86400 times as much). No way you are going
to fill up your sequence (well, about 86 million times as fast)
in your liftime.

Unless I'm mistaken (and my math isn't what it used to be): bullocks!

Hm - nobody noticed the error in the numbers?
The Number datatype can store numbers with magnitudes between
1*10^-130 and 9.99...9*10^125 (38 nines, followed by 88 zeros),
with *38 digits of precision*.

So, actually, I was about a factor 10^88 off - minor detail, as
the earth still ceased to exist

--
Regards,
Frank van Bortel
we would have caught it in production and issues a help desk ticket on it.

++ mcs




Reply With Quote
  #17  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-21-2005 , 05:56 AM



Mark C. Stock wrote:
Quote:
we would have caught it in production and issues a help desk ticket on it.

++ mcs

But only *after* you ran into it, eh?
<g>
--
Regards,
Frank van Bortel


Reply With Quote
  #18  
Old   
Paul
 
Posts: n/a

Default Re: reset a sequence in a trigger - 05-21-2005 , 06:00 AM




Frank van Bortel <frank.van.bortel (AT) gmail (DOT) com> wrote:


Quote:
Unless I'm mistaken (and my math isn't what it used to be): bullocks!

That's bollocks (or the Dublin variation bollix).

g> - thankx. Would Someone rather have maths instead of math?!?

To the best of my knowledge, bollocks is a term unknown to Merkans, so
variant spelling vis-à-vis western-Atlantikers does not apply.


Paul...


--

plinehan __at__ yahoo __dot__ __com__

XP Pro, SP 2,

Oracle, 9.2.0.1.0 (Enterprise Ed.)
Interbase 6.0.2.0;

When asking database related questions, please give other posters
some clues, like operating system, version of db being used and DDL.
The exact text and/or number of error messages is useful (!= "it didn't work!").
Thanks.

Furthermore, As a courtesy to those who spend
time analyzing and attempting to help, please
do not top post.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.