SQLite equivalent to ISNULL(), NVL(), IFNULL() or COALESCE()

前端 未结 6 967
夕颜
夕颜 2020-11-30 00:56

I\'d like to avoid having many checks like the following in my code:

myObj.someStringField = rdr.IsDBNull(someOrdinal) 
                            ? string.         


        
6条回答
  •  被撕碎了的回忆
    2020-11-30 01:32

    If there is not ISNULL() method, you can use this expression instead:

    CASE WHEN fieldname IS NULL THEN 0 ELSE fieldname END
    

    This works the same as ISNULL(fieldname, 0).

提交回复
热议问题