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 Nov 1, 2022

DB2 SQL join with USING need to support nullable column

I have a problem with a JOIN when columns are nullable.


summary:

I ask for an correction of the USING feature : in the sql engine do a IS NOT DISTINCT FROM when the column is nullable, so USING will do its job.


details:

for a better explanation, you can reproduce the problem with this sequence:

create table qtemp.autinf as ( select * from QSYS2.AUTHORIZATION_LIST_INFO ) with data
;

in this table, there are always either oname is null or path_name is null


when I try to join the table on itself with a USING


select
AUTH_LIST, ONAME, OSCHEMA, PATH_NAME, SYS_OTYPE
from qtemp.autinf B join qtemp.autinf A using(
AUTH_LIST, ONAME, OSCHEMA, PATH_NAME, SYS_OTYPE )
;

the resulset is empty.
translation in user language: the "keys" in file B are not in file A. inconsistant.


The reason is : NULL values never "equal" each other
the right way is to use the IS DISTINCT FROM clause


select
b.AUTH_LIST, b.ONAME, b.OSCHEMA, b.PATH_NAME, b.SYS_OTYPE
from qtemp.autinf B join qtemp.autinf A
on ( b.AUTH_LIST is not distinct from a.AUTH_LIST
and b.oname is not distinct from a.oname
and b.oschema is not distinct from a.oschema
and b.path_name is not distinct from a.path_name
and B.SYS_OTYPE = a.SYS_OTYPE)
;

a few ugly and difficult to explain to user. For my users, the concept of null is just foggy.



I would like to be able to use
USING (AUTH_LIST, ONAME, OSCHEMA, PATH_NAME, SYS_OTYPE )

I ask for an correction of the USING feature : in the sql engine do a IS NOT DISTINCT FROM when the column is nullable, so USING will do its job;
and probably more performant because the verification of
b.AUTH_LIST = a.AUTH_LIST
is restricted to the case where both values ar not null ... that is to say, null values are verified before the equal.

Idea priority Medium
  • Guest
    Reply
    |
    Nov 10, 2022
    IBM does not intend to provide a solution to this Idea at this time, so it is being closed.

    The null behavior of the JOIN USING clause is defined by the SQL standard. It is not something we can modify. While we could consider adding proprietary syntax to implement your suggestion, the database team has many other higher priority requests it is working on so this Idea would be unlikely to be implemented anytime soon.

    The work around it to expand the comparisons yourself using the DISTINCT predicate.


    Db2 for i development team
    IBM Power Systems Development