Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2003
    Location
    Des Moines,IA
    Posts
    21

    Question Unanswered: Can use NULL in select condn. in UDB DB2

    Hi

    We are converting Sybase to UDB

    In sybase in some places we are using the following type of sqls.

    select null,* from tablea
    go

    where as the same is not working in UDB.

    If anybody know the solution please reply me.
    I will apprciate.

    regards,
    Sreeni.

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    For those people who don't know Sybase, it might help if you can explain what you are trying to accomplish and see if someone can come up with the SQL that works with DB2.

  3. #3
    Join Date
    Jul 2003
    Location
    Des Moines,IA
    Posts
    21

    How to use NULL in SELECT ?

    Originally posted by Marcus_A
    For those people who don't know Sybase, it might help if you can explain what you are trying to accomplish and see if someone can come up with the SQL that works with DB2.
    Thanks for the reply.
    Here is the situation.

    select TN.NID, NAME, TC.CID, COLOR
    from TN
    left outer
    join TNC
    on TN.NID = TNC.NID
    inner
    join TC
    on TC.CID = TNC.CID

    union all
    select null, null, TC.CID, COLOR /* select null is not working in UDB */
    from TNC
    right outer
    join TC
    on TC.CID = TNC.CID
    where TNC.CID is null


    Hope you could understand this sql.

  4. #4
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    You need to use CAST function.

    Sintax:
    CAST (NULL AS data-type)

    Sample for char type:
    CAST (NULL AS CHAR(10))

    Sample for integer type:
    CAST (NULL AS INTEGER)

    For migrating from Sysbase to DB2 UDB you should also read the notes of sathyaram_s at http://dbforums.com/t853460.html

    Hope this helps,

    Grofaty

  5. #5
    Join Date
    Jul 2003
    Location
    Des Moines,IA
    Posts
    21

    Re: Can use NULL in select condn. in UDB DB2

    Originally posted by sakalasreenu
    Hi

    We are converting Sybase to UDB

    In sybase in some places we are using the following type of sqls.

    select null,* from tablea
    go

    where as the same is not working in UDB.

    If anybody know the solution please reply me.
    I will apprciate.

    regards,
    Sreeni.
    Thank you very much that will work for me ...

  6. #6
    Join Date
    Sep 2015
    Posts
    1
    The SELECT NULL doesn't work in DB2, it simply replace by SELECT NULLIF(0,0)

  7. #7
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by boihue View Post
    The SELECT NULL doesn't work in DB2, it simply replace by SELECT NULLIF(0,0)
    NULLIF(0,0) will return a NULL integer. What if you want a different data type? This question was satisfactorily answered 12 years ago.

    Andy

Posting Permissions

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