Android Question Strange behavior of null value returned from database

Discussion in 'Android Questions' started by MrKim, May 11, 2019.

  1. MrKim

    MrKim Active Member Licensed User

    I am trying to figure out how to get consistent results from Null. jtds database driver returns something "sort of like" null - but different. I just need to consistently test for null.
    See results below:

    ActiveEmp.PassWord has been initialized:
    Set to B4A Null:

    Set to Null returned by database/driver:
  2. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Can you show the SQL that gets the data into Crsr?
    Are you aware of the coalesce function?

  3. Mahares

    Mahares Well Known Member Licensed User

    You can probably use the ifnull function:
    ActiveEmp.Password =Starter.SQL1.ExecQuerySingleResult2("SELECT ifnull(Emp_BadgeNum,'') FROM mytable WHERE user LIKE ?", _
    Array As String("%MrKim%"))  'note 2 single quotes after Emp_BadgeNum,
  4. MrKim

    MrKim Active Member Licensed User

    Good Idea. Out of habit I try to keep server side processing to a minimum and do busy work like this on the WS/tablet where there is plenty of spare CPU power but in this case probably not.

    in TSQL it is IsNull, not IfNull but as with Coalesce, also a good idea, thanks.
    Last edited: May 13, 2019
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice