Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Not under consideration
Workspace IBM i
Categories Db2 for i
Created by Guest
Created on Feb 1, 2019

IBM DB2 SQL Table: Database Manger Identity / Duplicate Key

SQL Table created in IBM Navigator for I. Identity column created as decimal, 9 in length. Database manager generates value is set to always and cycle values when the maximum or minimum value is reached is checked. There is also a primary key constraint on this column. The issue is that when the identity is cycled the database manager can use a value that is already in use. We have run into this and it has caused many issues. IBM support is telling me that this will happen when cycle values is selected. I would suggest that the database manager should be smart enough to handle this number 1. If this is not possible, at the very least you should warn the user when cycle is selected that a duplicate key is possible with this selection. This should be documented everywhere around this. Very disappointed


Use Case:

I have table that has rows setup as default and working. Every day new working rows are setup as default. Default can be added whenever. Working rows are removed from the system after period of time. Default rows are managed by users. When the identity rolls over, the identity assigned by the database manager is already in use by the default rows and left over working rows that have not been deleted by cleanup process. The SQL inserts are just ignored while RPG program are blowing up


Idea priority High
  • Guest
    Reply
    |
    Mar 27, 2019

    An identity value is by definition not unique. This is true in the ANS and ISO standard and true for Db2 for z/OS and Db2 for LUW as well.
    Even if you do not specify CYCLE, you still could get duplicate values if you use OVERRIDING SYSTEM VALUE on INSERT or UPDATE.
    If you want identity columns to be guaranteed to be unique you must either add a unique constraint to the column or create a unique index.
    In either case, you would then choose whether you want NULL values to be considered to be unique or not.

  • Guest
    Reply
    |
    Mar 18, 2019

    NO CYCLE is the default when you create a table. The documentation in CREATE TABLE already points out the possibility of duplicate keys:

    CYCLE
    Specifies that values continue to be generated for this column after the maximum or minimum value has been reached. If this option is used,
    after an ascending sequence reaches the maximum value of the sequence, it generates its minimum value. After a descending sequence
    reaches its minimum value of the sequence, it generates its maximum value. The maximum and minimum values for the column determine
    the range that is used for cycling.

    When CYCLE is in effect, duplicate values can be generated by the database manager for an identity column. If a unique constraint or
    unique index exists on the identity column, and a non-unique value is generated for it, an error occurs.

  • Guest
    Reply
    |
    Feb 4, 2019

    I agree with Josys36. That is not part of the database itself.

    IMHO it should be handled at the application layer. If you still need a not-used id on the next "call" then use a SQL sequence and roll your own. Not that hard.

  • Guest
    Reply
    |
    Feb 4, 2019

    I don't agree with this request. I agree it would be nice if Navigator did some of these things. But, in all database products there are things that a database engineer is just going to have to know. That is why we always make our ID fields large enough to compensate for roll over.