![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
| Hi, Can anyone please tell me what a Sequence Record is and how it is used? Thanks, Shirley |
#3
| |||
| |||
|
|
shirley.cohen (AT) gmail (DOT) com wrote: Hi, Can anyone please tell me what a Sequence Record is and how it is used? Thanks, Shirley A sequence is simply an integer that is guaranteed to be unique among competing concurrent tasks. Typically, they are used as primary keys in a database. If you have multiple threads inserting records into a database, and you need the key to be unique, a sequence is the best way to do it. You could do your own sequence by inserting a single record into a database with the value being your integer. Then, when you need the next value, you would lock the record, read it remembering the value somewhere, increment it, write the new value into the same record, and then unlock it, so that other processes could do the same. You could then use that value as a key to insert your new data into your primary database. In DB, they've done all that work for you. You create a sequence object that is tied to a record in a database. You can set up your sequence with an initial value as well as an increment amount (say you want to increment by 5 instead of 1). You can also set a maximum value and whether you want the sequence to wrap when you hit the maximum or just throw an error. SleepyCat has provided some sample code in ex_sequence.c. -Joe -- |
![]() |
| Thread Tools | |
| Display Modes | |
| |