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

前端 未结 6 964
夕颜
夕颜 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:24

    You can easily define such function and use it then:

    ifnull <- function(x,y) {
      if(is.na(x)==TRUE) 
        return (y)
      else 
        return (x);
    }
    

    or same minified version:

    ifnull <- function(x,y) {if(is.na(x)==TRUE) return (y) else return (x);}
    

提交回复
热议问题