Sequence numbers not generated sequentially?

Our situation: We have encountered an issue with our database, where it appears that a sequence has generated a number out of sequence, that is, to fill in a gap left previously. That is, in the affected table, we have records like:
Seq No Date (DD/MM/YY)
1 29/12/08
2 29/12/08
3 4/1/09
4 29/12/08
The code that actually updates the database is from a third party, so I am unable to prove the following, but the vendor assures me that:
1. The sequence numbers are generated using "select message_number.nextval from dual".
2. The Date column is not modified after the record is created. ( Nor is it supposed to be )
The sequence is created by "CREATE SEQUENCE MESSAGE_NUMBER START WITH 10000000 INCREMENT BY 1 MINVALUE 10000000 CACHE 20 NOCYCLE NOORDER"
This was detected only yesterday, after the event, and is very uncommon ( I have not found another instance, but there are over 7,000,000 records, so I haven't performed an exhaustive search). We are relying on the sequence numbers always being generated sequentially, as in each message_number.nextval is greater than the previous one.
I don't think that the date change was due to a user accidentaly changing the date. Related records to '3' are also dated 4/1/09, there is no facility for a user to change the date outside of accessing the database directly, and even the developers do not have write access to this database.
My questions:
1. Is this normal behaviour for a sequence? To go back and fill in a gap like this? If so we'll have to change one of the assumptions of one of our modules.
2. Should the sequence be defined with 'ORDER' rather than 'NOORDER' to stop this?
3. Could this be a bug in the sequence number generation? We are using Oracle 9.2.0.1.0.
4. Is this situation "impossible", and therefore there is a bug in the vendor library that we need to track down.
Thanks for your help,
Wayne.

wayneb wrote:
Our situation: We have encountered an issue with our database, where it appears that a sequence has generated a number out of sequence, that is, to fill in a gap left previously. That is, in the affected table, we have records like:
Seq No Date (DD/MM/YY)
1 29/12/08
2 29/12/08
3 4/1/09
4 29/12/08
The code that actually updates the database is from a third party, so I am unable to prove the following, but the vendor assures me that:
1. The sequence numbers are generated using "select message_number.nextval from dual".
2. The Date column is not modified after the record is created. ( Nor is it supposed to be )There might be a delay between fetching the sequence and storing the sysdate? value in the database.
maybe some user prepared a new record. Then went to some new years eve party and when he came back at the begining of next year he commited the data (record send to database, database is adding date column by some trigger...).
>
The sequence is created by "CREATE SEQUENCE MESSAGE_NUMBER START WITH 10000000 INCREMENT BY 1 MINVALUE 10000000 CACHE 20 NOCYCLE NOORDER"
This was detected only yesterday, after the event, and is very uncommon ( I have not found another instance, but there are over 7,000,000 records, so I haven't performed an exhaustive search). We are relying on the sequence numbers always being generated sequentially, as in each message_number.nextval is greater than the previous one.
I don't think that the date change was due to a user accidentaly changing the date. Related records to '3' are also dated 4/1/09, there is no facility for a user to change the date outside of accessing the database directly, and even the developers do not have write access to this database.
My questions:
1. Is this normal behaviour for a sequence? To go back and fill in a gap like this? If so we'll have to change one of the assumptions of one of our modules.No sequences don't fill gaps. However it is possible to fetch and cache values from a sequence for later usage. Especially in a RAC environment you can get sequence values that are not in order of time.
2. Should the sequence be defined with 'ORDER' rather than 'NOORDER' to stop this?No.
3. Could this be a bug in the sequence number generation? We are using Oracle 9.2.0.1.0.Extremly unlikely, but you can always check Metalink.
4. Is this situation "impossible", and therefore there is a bug in the vendor library that we need to track down.You can create such situations programatically. Whether it is a bug depends on the specifications for the software.
>
Thanks for your help,
Wayne.Edited by: Sven W. on Mar 24, 2009 5:00 PM

Similar Messages

  • Business Partner numbers not generating in sequence

    Hello,
    For Business Partners, there are 2 Groupings maintained i.e. 1 for External Party and 1 for Employees. For both the groupings, internal number assignment has been maintained in T code BUCF. Also, "Define Groupings and Assign Number Ranges" has been assigned the relevant Group with the Number Range and the radio button for "Int.Std.Grping" is NOT checked.
    The issue faced is that while creating Business Partners, the BP numbers are not generated sequentially, For e.g if First BP number is 30000000, 30000001, then the next number generated is 30000010, 30000020, 30000021, 30000030..
    Not really sure why this would happen. There are no separate customer created in these account groups directly in FI.
    Also, when my Last BP number is 30000030 in T code BP  (SEARCH - BP - NUMBER), my Number range shows 30000039 as the "Current Number"
    Request your suggestions.
    Thanks,
    Murtuza.
    +91 99232 05169.
    Edited by: Murtuza Bootwalla on Dec 22, 2010 1:36 PM

    Hi,
    Please go to TCode SNRO and check if the buffering is active for object BU_PARTNER.
    If yes, you should disable it to have a sequential numbering.
    Go to Edit menu - set up buffering - no buffering
    Best regards,
    Itajaci Júnior

  • Shopping cart number not generating sequentially

    Hi Gurus,
                  While creating SC the SC number is not generating continuously. It is creating like this 345,346,349,340,345,.... Pls guide as soon as possible.
    Thanks,
    Suguna

    Suguna,
    If main memory buffering is ON, performance is improved but you will have gaps in your numbering assignment.  This can not be avoided f you turn buffering off, then the program will go directly to the atabase server for the next document number and not the application servers.  With this, there would be no gaps in numbering, but performance could be slowed.  Please see also the note 504875.
    To check what is set within your system;                                  
    Enter transaction SNRO -> obj: REQREQ and check whether 'Main memory buffering; is flagged and the value located with the 'no. of numbers in buffer'.      
    Regards,
    Peter

  • Generating sequence numbers not stored in the database

    how to generate row numbers in the select statement
    I need my query to return row numbers as a column which need to be displayed in the front end reporting tool.
    should return something like this..
    RANK NO DEPTID DEPT_NAME
    1 10 SCOTT
    2 10 JAMES
    3 20 PETER

    Something like
    SELECT row_number() over (order by deptid) rank_no, deptid, dept_name
      FROM deptJustin

  • Why the snap_id is not generated sequentially in statspack?

    I submitted some snaps manually, and thru dbms_job, the snap_ids are not sequential:
    SQL> select SNAP_ID,to_char(SNAP_TIME,'DD-MON-YY HH24:MI') timestamp from stats$snapshot order by 1;
    SNAP_ID TIMESTAMP
    1 22-AUG-06 08:19
    2 22-AUG-06 08:19
    3 22-AUG-06 08:26
    4 22-AUG-06 08:26
    11 22-AUG-06 10:32
    22 22-AUG-06 12:26
    31 23-AUG-06 07:53
    32 23-AUG-06 08:29
    41 23-AUG-06 19:00
    42 23-AUG-06 23:00
    51 24-AUG-06 03:00
    52 24-AUG-06 07:00
    Could someone explain? Thanks.
    - Zack

    It probably generates the snap_id using a sequence with a cache value of 10. When the shared pool is flushed or the db is shutdown the cached values will be lost.

  • Ipsec sequence numbers not working for multi VPN's

    one site to one site VPN works no problem, but when I add the second peer in the hub router it does not connect. There is no routing in place all routers are connected to the same switch and with no crypto map they can both ping 192.168.2.1. With crypto map only 192.168.2.2 can ping 192.168.2.1. I am at a loss as to what I am doing wrong this seems simple I just add the entry to Test with a different number, but it will not work.
    Please ask any other question you can think of. I followed the same commands on both spoke routers so it seem like it would be in the hub router, but it has me beat as to why.
    Thanks for the help.
    Hub router:
    r1#sh crypto map
    Crypto Map Test 1 ipsec-isakmp
            Peer = 192.168.2.2
            Extended IP access list 110
                access-list 110 permit ip any any
            Current peer: 192.168.2.2
            Security association lifetime: 4608000 kilobytes/86400 seconds
            PFS (Y/N): N
            Transform sets={
                    Test,
            Interfaces using crypto map Test:
                    FastEthernet0/0
    Crypto Map Test 2 ipsec-isakmp
            Peer = 192.168.2.3
            Extended IP access list 110
                access-list 110 permit ip any any
            Current peer: 192.168.2.3
            Security association lifetime: 4608000 kilobytes/86400 seconds
            PFS (Y/N): N
            Transform sets={
                    Test,
            Interfaces using crypto map Test:
                    FastEthernet0/0
    r2#sh crypto map
    Crypto Map Test 1 ipsec-isakmp
            Peer = 192.168.2.1
            Extended IP access list 110
                access-list 110 permit ip any any
            Current peer: 192.168.2.1
            Security association lifetime: 4608000 kilobytes/86400 seconds
            PFS (Y/N): N
            Transform sets={
                    Test,
            Interfaces using crypto map Test:
                    FastEthernet0/0
    r3#sh crypto map
    Crypto Map Test 1 ipsec-isakmp
            Peer = 192.168.2.1
            Extended IP access list 110
                access-list 110 permit ip any any
            Current peer: 192.168.2.1
            Security association lifetime: 4608000 kilobytes/86400 seconds
            PFS (Y/N): N
            Transform sets={
                    Test,
            Interfaces using crypto map Test:
                    FastEthernet0/0

    Ok I cannot ping anything now. Can you see any other obvious problems? Seems like I should be close and must be missing something simple.
    Thanks for the help by the way.
    hostname r1
    crypto isakmp policy 9
    authentication pre-share
    crypto isakmp key Test1234 address 192.168.2.2
    crypto isakmp key Test1234 address 192.168.2.3
    crypto ipsec security-association lifetime seconds 86400
    crypto ipsec transform-set Test esp-3des esp-sha-hmac
    crypto map Test 1 ipsec-isakmp
    set peer 192.168.2.2
    set security-association lifetime seconds 86400
    set transform-set Test
    match address 110
    crypto map Test 2 ipsec-isakmp
    set peer 192.168.2.3
    set security-association lifetime seconds 86400
    set transform-set Test
    match address 111
    spanning-tree mode pvst
    interface FastEthernet0/0
    ip address 192.168.2.1 255.255.255.0
    duplex auto
    speed auto
    crypto map Test
    interface FastEthernet0/1
    no ip address
    duplex auto
    speed auto
    shutdown
    interface Vlan1
    no ip address
    shutdown
    ip classless
    access-list 111 permit ip host 192.168.2.1 host 192.168.2.3
    access-list 110 permit ip host 192.168.2.1 host 192.168.2.2
    line con 0
    line vty 0 4
    login
    end
    hostname r2
    crypto isakmp policy 9
    authentication pre-share
    crypto isakmp key Test1234 address 192.168.2.1
    crypto ipsec security-association lifetime seconds 86400
    crypto ipsec transform-set Test esp-3des esp-sha-hmac
    crypto map Test 1 ipsec-isakmp
    set peer 192.168.2.1
    set security-association lifetime seconds 86400
    set transform-set Test
    match address 110
    spanning-tree mode pvst
    interface FastEthernet0/0
    ip address 192.168.2.2 255.255.255.0
    duplex auto
    speed auto
    crypto map Test
    interface FastEthernet0/1
    no ip address
    duplex auto
    speed auto
    shutdown
    interface Vlan1
    no ip address
    shutdown
    ip classless
    access-list 110 permit ip host 192.168.2.2 host 192.168.2.1
    line con 0
    line vty 0 4
    login
    end
    hostname r2
    crypto isakmp policy 9
    authentication pre-share
    crypto isakmp key Test1234 address 192.168.2.1
    crypto ipsec security-association lifetime seconds 86400
    crypto ipsec transform-set Test esp-3des esp-sha-hmac
    crypto map Test 1 ipsec-isakmp
    set peer 192.168.2.1
    set security-association lifetime seconds 86400
    set transform-set Test
    match address 110
    spanning-tree mode pvst
    interface FastEthernet0/0
    ip address 192.168.2.2 255.255.255.0
    duplex auto
    speed auto
    crypto map Test
    interface FastEthernet0/1
    no ip address
    duplex auto
    speed auto
    shutdown
    interface Vlan1
    no ip address
    shutdown
    ip classless
    access-list 110 permit ip host 192.168.2.2 host 192.168.2.1
    line con 0
    line vty 0 4
    login
    end

  • @SequenceGenerator generating wrong sequence numbers on an Oracle database

    Hello,
    I have a JPA entity with the following annotation:
    @SequenceGenerator(name = "PERS_GEN", sequenceName = "PERS_SEQ", initialValue = 1, allocationSize = 1)
    But the ids created by this sequence are not incrementing one by one;they increment 20 by 20. What is the cause of this?And how can it be sold?

    Hello,
    You will need to reference the database docs on what the database cache setting means or how it behaves, or post on the JDBC forums as I don't really know. My testing by calling SELECT seq.NEXTVAL FROM dual repeatedly caused it to return numbers sequentially based on the increment by value. I suspect this was because I was using the same session/connect etc and might be different if using different connections, timing etc. Have you tried creating the sequence with the nocache option? The cache 20 is not something that would be set by EclipseLink and is likely a database default, and I do not see why START WITH 21 would be used if the annotation specified initialValue = 1 - how are you checking the sequence that gets created? You can turn on EclipseLink logging to Finest to see the SQL it generates, but I would suggest you create the sequence object yourself - or have JPA create a DDL file and use it to create the tables. See http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_Extensions_for_Schema_Generation for ddl generation options.
    I found this http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:369390500346406705 discussion on database sequence cache sizes that might help.
    Regards,
    Chris

  • Inconsistent sequence numbers generated

    We just ran into an unexplained occurrence using a sequence table.
    Suddenly it started assigning id number millions higher than the sequence it was previously filling. As you can see in the log the original range was in the 19 million area and then it began inserting values in the 28 million range.
    Here is the id sequence it put in (I realize these are not exactly sequential because it does not commit them in the same order it allocates them.)
    Previous transaction
    many ids, the last one is...
    19712292
    Problematic transaction
    28064436 ---> ???
    19741496
    19728823
    19742100
    19741852
    28064408 ---> ???
    19726424
    28064433 ---> ???
    19737253
    etc...
    I have no idea where these 28 million series numbers came from. It was a large transaction but I certainly did not insert 9 million rows.

    I have some occasional spawned threads that read, but only the primary thread writes.
    No JTA
    Yes they are in the same transaction
    Yes the same thread, session and connection are used by both. Here is a portion of the log.
    [TopLink Fine]: 2007.04.28 08:15:37.208--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (28064436, 'a')
    [TopLink Fine]: 2007.04.28 08:15:37.230--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (19741496, 'b')
    [TopLink Fine]: 2007.04.28 08:15:37.236--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (19728823, 'c')
    [TopLink Fine]: 2007.04.28 08:15:37.241--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (19742100, 'd')
    [TopLink Fine]: 2007.04.28 08:15:37.247--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (19741852, 'e')
    [TopLink Fine]: 2007.04.28 08:15:37.252--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (28064408, 'f')
    [TopLink Fine]: 2007.04.28 08:15:37.259--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (19726424, 'g')
    [TopLink Fine]: 2007.04.28 08:15:37.264--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (28064433, 'h')
    [TopLink Fine]: 2007.04.28 08:15:37.270--UnitOfWork(25076495)--Connection(29197673)--Thread(Thread[AJPRequestHandler-RMICallHandler-1,5,RequestThreadGroup])--INSERT INTO Q_TBL (ID, ALIAS) VALUES (19737253, 'i')

  • Generate sequence numbers

    Hi,
    I am looking for an algorithm to generate alphanumeric sequence numbers in ABAP.
    The sequence numbers should be in the following format
    AAAA
    AAAB
    AAAC
    AAAZ
    AABA
    AABB
    AABC
    AABZ
    ZZZZ
    Is there any built-in function module provided by SAP to accomplish this? Or something like a FOR statement as in C/C++?
    Please help.
    Helpful answers will be immediately rewarded.
    Thank you.

    Hi,
    I'm not sure, but maybe you can create a number range with SNRO for alphanumerical values
    otherwise you have to create your own logic (you can use hexadecimal to ascii conversion in ABAP to increment the alphanumerical values)
    Kind regards, Rob Dielemans

  • Contract Terms-Document sequence was not found for generating clause number

    Hi All,
    I am in very strange situation and not able to find out the solution for below problem.
    when i am trying to create clause number from Contracts Terms --> Contract Terms Library : Clauses , i found below error.
    " Document sequence was not found for generating clause number. Check the document sequence setup."
    where i have setup the document sequence setup? Please help me how to resolve this issue.
    Thanks in advance.
    Edited by: user627525 on Feb 8, 2011 7:25 AM

    Hi,
    I have the same error when trying to create clause number from Contracts Terms --> Contract Terms Library : " Document sequence was not found for generating clause number. Check the document sequence setup."
    Would you like to tell me how did you solve it, please?
    Regards,
    tinar

  • How to generate random sequence numbers

    Hello experts
    Iu2019m writing a custom program and pulling data from VBAK & VBAP. As per requirement I also need to generate a sequence number randomly and finally store all data in text file and upload at server. The hiccup is I donu2019t know how to generate sequence numbers. Can somebody please show me how I can accomplish it?
    Thanks a lot in advance

    Find the below code,
      data: lv_range type datatype-char0128.
      call function 'RANDOM_C'
        exporting
          len_min   = 20
          len_max   = 20
          char_min  = 1
          char_max  = 20
        importing
          rnd_value = lv_range.
    LV_RANGE param will have a random value..
    If you need number you can use the FM "RANDOM_I4"
    Thanks,
    Prathap

  • Generate Sequential values for a column

    Hi,
    I had a column in named 'ID' in the block of my form. I want to generate sequential values for the column without using sequence. Suppose if the table does not have any data it has display the starting value what i am providing.(ex. 101).If the data is there in the table If i am executing the query in the last null record it has to show the maxvalue+1 for that column. where can I write the code to get this logic? How to write the code? Can any body please solve my problem?
    Thanks in advance
    user1

    Why don't you want to use a sequence? Do the ORDID values have to be sequential without any gaps in between?
    If so, this requirement is quite hard to achieve in multi-user environment.
    Some approaches:
    Select the next available value from the database when creating a new record , e.g. in the WHEN-CREATE-RECORD-Trigger:
    DECLARE
      CURSOR crMax IS
        SELECT NVL(MAX(ORDID), 0)+1
          FROM ORD;
    BEGIN
      OPEN crMax;
      FETCh crMax INTO :ORD.ORDID;
      CLOSE crMax;
    END;Pros: The user can see the new value when he starts entering the data.
    Contras: When another user uses the same form to create a new record between the point of time user 1 starts entering the record and the point of time he saves, the same number will be taken again which will fail on insert for the second user (i assume there is a Unique Key on ORDID).
    Result: This approach is not suitable in a multi-user environment.
    Second approach:
    Use the same logic as in approach 1, but select the next available number in the PRE-INSERT-trigger of the block:
    Pros: The problem of approach 1 with two users getting the same number gets much more unlikely, for in general the COMMIT goes quite short after the PRE-INSERT has fired, so there will only be problems if both users save at the same moment.
    Contras: Problem with duplicate numbers can still occur iunder special circumstances. The number is not shown until the Insert is issued against the database.
    Result: This approach is possible, but you have to decide if the restrictions are bearable for your situation.
    Further approaches:
    Create a "Number table" either with just one record and one column which contains the next suitable number (lets say TAB_ORDID with column NEXT_ORDID) or with a number of records containing the next suitable numbers.
    Then with the usage of SELECT FOR UPDATE you can lock a record, take the number from it and either update the row to the next value (one row apporach)or delete the row retrieved (multi row approach). Both cases require some more complex logic for retrieving the next number and can cause some trouble in multi-user-environments (ending up in all users who want to create records waiting for the one user who started and did not save correctly) if the locks are not handled correctly.

  • Temporary sequence numbers

    Hello all,
    Is there any provision in the mobile server and mobile client to synchronize the Lite database by using temporary sequence numbers for the newly added records?
    In the application that we are involved with, we are being asked to provide this behavior.
    In details we would ensure that the sequence generation works as it works for the desktop PCs as well.
    As far as we know we should follow the following steps for the synchronization:
    1. sync new rows with the server
    1a. the server syncs with the database, replaces temporary seqnos with the ones that come from the database
    2. sync the new seqnos back to the mobile device...
    Please let me know whether it is possible or not with the Oracle Lite system,
    Thanks in advance,
    Balazs

    do you have some need to keep the range of DONOR_ID sequential?
    In our implementation we use the other method that Greg has mentioned, defining sequences within the oracle lite publication itself
    We use sequence generated ID values as the primary key on a lot of our tables, and the columns are defined as NUMBER(12) (reasons are historical, and not necessarly for any good reason - but stuck with it)
    looking at the worst case scenario (to keep things simple) in the server we have table PLOTS. The highest ID value is around 5.5 million, with an annual growth rate of 500,000 for server created records. The number of records that would be created on any particular client on an annual basis is more like 2,000.
    When you define a sequence within the mobile server you specify a 'template' for each sequence consisting of
    name (eg: PLO_ID_SEQ)
    start value
    increment
    window (number of values to assign to a particular user)
    threshold (point at which the next set of values is sent to the user)
    for PLO_ID_SEQ, the start value is set at 500 million (overkill, but server generated id values will never reach this point in practice), increment is 1, window = 100,000 and threshold is 95,000
    This in practical terms means that the sequences on the clients will never need to be re-sent as the values will never reach the threshold, and there will never be any cross over with server generated sequences
    When you add your first client to the application, the actual sequence start value will be set for that client as 500,000,000. for the second user added it will be 500,100,000, for the third 500,200,000 etc.
    On the whole the mobile server manages this ok, but we have found that if there is a need to replace a client by rebuilding the database from scratch, occasionally it does not correctly maintain the last value used. To get around this we reset the user prior to the rebuild (this resets the sequence start for that user to the next range of values)
    This works ok, and is straightforward to implement as you need no code change/data manipulation on the server, but does result in the source of the records being obviously different (can be useful), and you cannot assume that the highest id value is the most recent record (can be a problem for reports)

  • Sequence numbers - with no gaps!

    I seek some advice from anyone with first hand experience in this area.
    My need is simple; generate a new ID number for every order for use as the primary key.
    Obviously this simple exercise could be a bottleneck as volumes ramp up, so I was pleased to find the Oracle feature to generate such numbers (efficiently presumably). However, upon closer reading it was apparent that aborted transactions would result in the loss of the number allocated to to that order if another transaction had obtained the next sequence number already (as one would want it to, rather than serializing transactions).
    I don't want to have gaps in the sequence as the system needs a high degree of auditability. I am thinking of utilising the Autonomous Transaction feature to write the newly acquired sequence number to the order file with a flag indicating that the record is incomplete, and that record is to be skipped by normal system applications (but available to audit reports which will interpret the reason correctly), then returning to the far more extensive main transaction which updates many tables.
    The other alternative is to control sequence numbers within the application itself, or try to get the sequence number as the very last step before writing the new order record, but this probably won't guarantee gapless reliability either. The ID itself has no significance, and it doesn't matter if an ID was used out of strict date/time sequence, so I really don't want to execute these updates serially.
    So, my question is this:
    a) do most people use the builtin sequence number feature?
    b) if so, is there a standard technique for avoiding or accounting for gaps?
    c) if the application must take over this task, should the counter for the last used ID be in a single row table to minimise bottlenecks caused by the thisrecord being locked? There will be several such counters for different aspects of the application, and i thought of having each in its own row in a small table, but I'm concerned about the whole table getting locked and freezing out otherwise-unrelated updates.
    Thanks for any advice you may have.
    CS

    user8821725 wrote:
    I seek some advice from anyone with first hand experience in this area.
    My need is simple; generate a new ID number for every order for use as the primary key.
    Obviously this simple exercise could be a bottleneck as volumes ramp up, so I was pleased to find the Oracle feature to generate such numbers (efficiently presumably). However, upon closer reading it was apparent that aborted transactions would result in the loss of the number allocated to to that order if another transaction had obtained the next sequence number already (as one would want it to, rather than serializing transactions).
    I don't want to have gaps in the sequence as the system needs a high degree of auditability. One of the very very few reasons for me to have a requirement for "gapless" sequences is if you have a kind of checking mechanism outside of the database that is implemented using this gapless number. I had such a requirement once, when exchanging files with another bank where we had to ensure that each file was transferred correctly and in the right order. Your "high degree of auditability" might be a similiar requirement. Just remember as long as you are still inside the database you can use other mechanisms to increase auditability.
    I am thinking of utilising the Autonomous Transaction feature to write the newly acquired sequence number to the order file with a flag indicating that the record is incomplete, and that record is to be skipped by normal system applications (but available to audit reports which will interpret the reason correctly), then returning to the far more extensive main transaction which updates many tables.Hm. I don't see why you want to use Autonomous Transactions for this. It might be useful to lessen locking conflicts , depending how your future sequence mechanism will be built.
    >
    The other alternative is to control sequence numbers within the application itself, or try to get the sequence number as the very last step before writing the new order record, but this probably won't guarantee gapless reliability either. The ID itself has no significance, and it doesn't matter if an ID was used out of strict date/time sequence, so I really don't want to execute these updates serially.I would go for generating the sequence as the very last step. It needs to be set to NOCACHE of cause. This will garantee that the sequence fetched from mySeq.nextval is gapless. The problem is then in your application. Your application must be built in a way that it ensures to use this sequence, or at least to create a noticable alert when this generated sequence can't be used anymore. In essence this means. Each unhandled (database) error that happens after you fetched the next sequence value must be raised in a way that informs all relevant people about this error.
    Example: It might be that you use the sequence to write an order file. What happens if halfway through writing the file your disk runs out of space? This can be such an issue where a sequenced value will be lost. Your organisation must take care of those things.
    >
    So, my question is this:
    a) do most people use the builtin sequence number feature?Yes. But for some tasks a sequence is not the best way, for example if you want a numbering for each item of your order. This "sequence" needs to restart with every new order.
    b) if so, is there a standard technique for avoiding or accounting for gaps?NOCACHE => Avoids gaps during generation
    Database Trigger => Tries to use the sequence as late as possible
    c) if the application must take over this task, should the counter for the last used ID be in a single row table to minimise bottlenecks caused by the thisrecord being locked? There will be several such counters for different aspects of the application, and i thought of having each in its own row in a small table, but I'm concerned about the whole table getting locked and freezing out otherwise-unrelated updates.This is a possibility and the issues you describe are why we avoid such a solution in general. Autonomous transactions help to reduce the locking conflict, but they increase the chance that you produce gaps.
    >
    Thanks for any advice you may have.
    CSOracle can guarantee to produce gapless sequences. But it can't guarantee that your application uses such a sequence in a gapless way.

  • Recycled Sequence Numbers

    Hi,
    We have a requirement of generating sequence numbers for a table and we need to recycle them if some of them is deleted.
    For example the following tabe Employee(Id,name)
    ID NAME
    1 XXX
    2 YYY
    3 ZZZ
    4 AAA
    The ID filed should have the next sequence number generated. When I call getnextID now, it should return 5
    ID NAME
    1 XXX
    2 YYY
    3 ZZZ
    4 AAA
    5 BBB
    Now Let us assume I delete 3. The contents of the table aare
    ID NAME
    1 XXX
    2 YYY
    4 AAA
    5 BBB
    Now when getNextID, 3 should be returned.
    How to achieve this in a best performing way in Oracle? Are there any patterns around it? Please note this should run in a multi user environment.
    Thanks,
    Rama

    I think the answers were based on the fact that you call it incorrectly sequence.
    Your ConnectivityID is more as a resource that could be recycled. I see some similarities to the GSM telecom market where a resource(i.e. a phone number or a SIM card no) can be recycled when is not active anymore (under certain conditions however).
    Personally I would generate a table of resources having the resource number (ConnectivityID) and resource status.
    To simplify it, suppose that you have column status with 2 possible values, 0=available, 1=not available.
    When you want to allocate the resource number(ConnectivityId) you will set the status to 1.
    When the record is deleted then status will be updated back to 0.
    Recycling a ConnectivityID will mean searching in the table for the lowest number having status=0.
    Of course you don't expect this to be as fast as a sequence but I think this is a different requirement, IMO.
    Regards
    Al

Maybe you are looking for

  • CX_HRPA_INVALID_PARAMETER

    hi Experts We have developed a function module which calculates certain amount based on certain criteria and update the amount in a wage type in Infotype 15. The function module calculates the amount , but when im trying to update infotype 15 using H

  • Fonts Not Available in Photoshop CS3 (Windows 7)?

    Hello, My desktop computer crashed yesterday and I had to run out last night and pick up a new unit as I'm trying to meet a number of deadlines (and not having much luck getting the work done in my laptop). The new computer uses Windows 7 as the Oper

  • Iconed labels and iconified JFrame

    Hello everybody, I have a problem with a strange behaviour of a JFrame. In order: 1. I initialize a JFrame with a JSplitPane 2. The left component is a JPanel containing 64 JLabels, each with an Icon in it. When the frame is coming up, everything is

  • Je n'arrive pas à utiliser ma carte RME fireface UFX....midi audio??  Aucun lien entre le Logic Pro 9 et la carte...rien n'y entre et rien ne sort. :(

    Je débute en Home Studio et je n'arrive pas à configurer ma carte de son RME fireface UFX pour l'utiliser avec Logic Pro et Main stage.  Aucun échange audio et aucun échange midi.  Par où dois-je commencer?  Configuration audio et midi dans les utili

  • Bluetooth from iMac G5 10.4.11 to MacBook 10.5.5

    Just bought a MacBook OS 10.5.5. I cannot send a file from my iMac to MacBook. I get a message "device does not have the necessary services". What does this mean and how do I do something about it? The two computers are paired and connected, bluetoot