Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-5006

Handle NULL literals like any other database

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 10.7.1.1
    • None
    • SQL
    • Normal

    Description

      Most RDMBS allow for typeless NULL values / literals just about anywhere in a SQL statement. I am not aware of SQL standards explicitly encouraging the enforcement of casts on NULL values and literals. Even DB2, the "mother of strongly typed databases" has finally given up type enforcement on NULL values / literals in version 9.7:
      http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.wn.doc/doc/i0054263.html

      I wonder, whether this would be a nice way to go for Derby as well? I am asking this from the perspective of a database abstraction library developer (http://jooq.sourceforge.net). I find it extremely difficult to cast NULL values to the correct type in every occasion, as in Java, null does not have a type. A good example for this is:

      SELECT cast(null as ...) FROM SYSIBM.SYSDUMMY1

      From the Java application's point of view, any type is OK, because it won't matter. But then, why would it matter to Derby?
      Another good example to me is this:

      INSERT INTO X (ID, NAME, NUMBER)
      SELECT (10, null, null)
      FROM SYSIBM.SYSDUMMY1

      This won't work. I'll need to rewrite it to something like this:

      INSERT INTO X (ID, NAME, NUMBER)
      SELECT (10, CAST(null AS VARCHAR(100)), CAST(null AS INTEGER))
      FROM SYSIBM.SYSDUMMY1

      When actually Derby could infer the types of null. Type inference is done sometimes. This will work:

      INSERT INTO X (ID, NAME, NUMBER)
      VALUES (10, null, null)

      What do you guys think?

      Attachments

        Activity

          People

            Unassigned Unassigned
            lukas.eder Lukas Eder
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: