Re: [GENERAL] Sequence question

2004-10-20 Thread Andrew Sullivan
On Wed, Oct 20, 2004 at 02:59:27PM -0400, Eric E wrote: > - have the sequence preallocation table hold only numbers with status > being available or pending, i.e., delete numbers once they have been > allocated. This leaves on two possible statuses: available and pending. I would argue that yo

Re: [GENERAL] Sequence question

2004-10-20 Thread Eric E
Hmm that's a really intesting idea, Tino. Since we're probably talking about 100 numbers max, a query on this table would work fairly fast, and operationally simple. I'll think about that. Thanks, Eric Tino Wildenhain wrote: Hi, Am Mi, den 20.10.2004 schrieb Eric E um 19:52: Hi Tin

Re: [GENERAL] Sequence question

2004-10-20 Thread Tino Wildenhain
Hi, Am Mi, den 20.10.2004 schrieb Eric E um 19:52: > Hi Tino, > Many thanks for helping me. > > I know that the sequence issue is a troubling one for many on the list. > Perhaps if I explain the need for a continuous sequence I can circumvent > some of that: > > This database is for a

Re: [GENERAL] Sequence question

2004-10-20 Thread Eric E
Hi Andrew, I had basically started working on an idea like the second approach, but had not been able to put the status element so clearly. I really like the statuses of available, pending, and granted. There's one more twist I think I can use to optimize this: once a number is assigned, it

Re: [GENERAL] Sequence question

2004-10-20 Thread Andrew Sullivan
On Wed, Oct 20, 2004 at 01:52:59PM -0400, Eric E wrote: > One thought I had, and I'd love to hear what people think of this, is to > build a table of storage location numbers that are available for use. > That way the search for new numbers could be pushed off until some > convenient moment wel

Re: [GENERAL] Sequence question

2004-10-20 Thread Eric E
Hi Tino, Many thanks for helping me. I know that the sequence issue is a troubling one for many on the list. Perhaps if I explain the need for a continuous sequence I can circumvent some of that: This database is for a laboratory, and the numbers in sequence determine storage locations f

Re: [GENERAL] Sequence question

2004-10-20 Thread Alvaro Herrera
On Wed, Oct 20, 2004 at 11:57:42AM -0400, Andrew Sullivan wrote: > Now, how do you handle the cases where either the transaction fails > so you can't set it to 3? Simple: your client captures errors and > then sets the value back to 1 later. Has anyone read "the Sagas paper" by Garcia-Molina? T

Re: [GENERAL] Sequence question

2004-10-20 Thread Andrew Sullivan
On Tue, Oct 19, 2004 at 11:19:05AM -0400, Eric E wrote: > My users will draw a number or numbers from the sequence and write to > the field. Sometimes, however, these sequence numbers will be discarded > (after a transaction is complete), and thus available for use. During > the transaction, h

Re: [GENERAL] Sequence question

2004-10-20 Thread Tino Wildenhain
Hi, On Tue, 2004-10-19 at 01:16, Eric E wrote: > Hi, > I have a question about sequences. I need a field to have values with > no holes in the sequence. However, the values do not need to be in order. > > My users will draw a number or numbers from the sequence and write to > the field.

Re: [GENERAL] Sequence question

2004-10-20 Thread David Ecker
Far from being a perfect idea but a faster solution than stepping through all holes: 1) Create a second table containing only one field of type of your key. 2) When you delete an entry place the delete key value in your second table 3) If you insert a new entry into your old table and your new tab

[GENERAL] Sequence question

2004-10-20 Thread Eric E
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from the sequence and write to the field. Sometimes, however, these sequence numbers will be discarded

[GENERAL] Sequence question

2004-10-20 Thread Eric E
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from the sequence and write to the field. Sometimes, however, these sequence numbers will be discarded (

Re: [GENERAL] Sequence Question

2004-08-05 Thread Oscar Tuscon
I'm not sure but I don't think that's safe since nextval doesn't lock the sequence until the setval occurs. Though it might be unlikely to actually occur in real life. You could create a table with as many entries as you will ever need and then select nextval() from that table and read all the

Re: [GENERAL] Sequence Question

2004-08-05 Thread Greg Stark
Oscar Tuscon <[EMAIL PROTECTED]> writes: > I'm looking at ways to get batches of sequence values s faster. I don't want to set > cache or increment to a large number for a variety of reasons. I need to grab id's > in batches of varying numbers at various times, from 1 to several thousand at once

Re: [GENERAL] Sequence question

2003-12-17 Thread John Sidney-Woollett
Sorry I should have added that the trigger needs to create a new keyword record if the join in the trigger fails to locate the keyword in the keyword table. Hopefully you can create the trigger yourself. The keyword table is effectively a distinct list of all keywords inserted into the data table

Re: [GENERAL] Sequence question.

2003-12-17 Thread John Sidney-Woollett
How about using two tables; one to hold the keyword and its (last allocated) sequence value, and the second to store your data as below. create table Keyword ( keyword varchar(32), sequence integer, primary key(keyword) ) create table Data ( id serial, sequence int, keyword varchar(32

[GENERAL] Sequence question.

2003-12-16 Thread Anthony Best
I'm working on an idea that uses sequences. I'm going to create a table like this: id serial, sequence int, keyword varchar(32), text text for every keyword there will be a uniq sequence for it eg: id, sequence, keyword 1, 1, foo, ver1 2, 1, bar, bar ver1 3, 2, foo, ver2 4, 2, bar, bar ver2 etc.