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:
    upload_2019-5-11_0-18-2.png
    Set to B4A Null:
    upload_2019-5-11_0-19-36.png

    Set to Null returned by database/driver:
    upload_2019-5-11_0-22-25.png
     
  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?

    RBS
     
  3. Mahares

    Mahares Well Known Member Licensed User

    You can probably use the ifnull function:
    Code:
    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
Loading...
  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