Android Question Strange behavior of null value returned from database

MrKim

Well-Known Member
Licensed User
Longtime 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:
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User

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

RBS
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
You can probably use the ifnull function:
B4X:
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,
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Can you show the SQL that gets the data into Crsr?
Are you aware of the coalesce function?

RBS
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:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…