Results 1 to 3 of 3

Thread: Hii all

  1. #1
    Join Date
    Sep 2013
    Location
    India
    Posts
    249

    Unanswered: Hii all

    I have created a table in db2 with colmns Sr_no,current timestamp,rowcount & the first coloumn Sr_no have been created as generated always as identity.I have created a script for the insertion of records automatically at an every 10min of interval through crontab.The problem is that the Sr_no is not incrementing sequentially & it is giving a diff of 20 at an every new record insertion and the with respect to script the database in between is going to connect and disconnect mode.


    SR_NO TS_RECORD ROW_COUNT
    ----------- -------------------------- ---------
    2 2017-07-07-15.38.42.500247 0.
    3 2017-07-07-15.39.12.823463 1.
    4 2017-07-07-16.03.54.863608 2.
    5 2017-07-07-16.06.21.911794 3.
    6 2017-07-07-16.07.35.354485 4.
    21 2017-07-07-16.38.21.474809 5.
    41 2017-07-07-16.39.14.038552 6.
    61 2017-07-07-16.42.25.370498 7.
    62 2017-07-07-16.46.42.573394 8.
    81 2017-07-10-15.00.02.441094 9.
    82 2017-07-10-15.10.02.648805 10.
    101 2017-07-10-15.20.02.824568 11.
    102 2017-07-10-15.30.02.985826 12.
    103 2017-07-10-15.40.02.143605 13.
    121 2017-07-10-15.50.04.113776 14.
    141 2017-07-10-16.00.02.656599 15.
    142 2017-07-10-16.10.02.861331 16.
    143 2017-07-10-16.20.03.035086 17.
    161 2017-07-10-16.40.04.463814 18.
    181 2017-07-10-16.50.04.834238 19.
    201 2017-07-10-17.10.02.386261 20.
    221 2017-07-10-17.20.04.370268 21.
    241 2017-07-10-17.30.04.698779 22.
    261 2017-07-10-17.40.04.553200 23.
    281 2017-07-10-17.50.04.984799 24.
    301 2017-07-10-18.10.04.851624 25.
    321 2017-07-10-18.20.04.276112 26.
    341 2017-07-10-18.30.04.647623 27.
    361 2017-07-10-18.40.04.429010 28.
    381 2017-07-10-18.50.04.771223 29.
    401 2017-07-10-19.10.04.034196 30.
    421 2017-07-10-19.20.04.412902 31.
    ssumit

  2. #2
    Join Date
    Apr 2012
    Posts
    1,143
    Provided Answers: 27
    That is the expected behaviour, because the identity column is most likely implemented by a sequence object, which probably has default cache size. Values from such objects are not guaranteed to be gapless, in the event of rollback or restarts. You can have no cache setting for the object but that also will not guarantee what you want and will negatively impact performance.

  3. #3
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    294
    Provided Answers: 45
    You lose all the remaining cached values for the sequence due to the database deactivation between connection attempts probably.
    Run the following command to make db2 not to deactivate the database when the last session disconnects it:

    db2 ACTIVATE DB MYDB
    Regards,
    Mark.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •