[rs objectForColumnName:@"xxx"];
If column xxx has no value, the above code returns NSNull, but directly judges
if(NSNull){ }
will be evaluated as true, thus executing the code in the curly braces. So the following code is wrong:
if([rs objectForColumnName:@"xxx"]){ // logic when column xxx has a value }
Even if column xxx has no value, it will go to the curly braces. The correct spelling should be:
NSNumber *defInt1 = [rs objectForColumnName:@"def_int1"]; if(![defInt1 isEqual:[NSNull null]]){ // logic when def_int1 has a value }