Questions tagged [null]

Null means *nothing* or *unknown*, depending on context. Please use the "sql-null" tag for SQL specific questions.

"Null" has different meanings depending on context.

Set theory

Null is another name for the empty set, denoted by the symbol ∅. For this reason, some programming languages use null or nil for the empty list or empty tuple. Lisp uses nil to mean the empty list and the boolean value false.

Pointers and References

Null (or sometimes nil or None), in programming languages that support it, is the value of an uninitialized variable, a pointer that doesn't point to a meaningful memory address, or an object that fails to respond to any message.

Nullable references were invented by C.A.R. Hoare in 1965 as part of the Algol W language. Hoare later described his invention as a "billion-dollar mistake".

For more information, see Null pointer.

Agreeing with Hoare's sentiment, many languages don't have a special null value, choosing to use optional types instead.

Relational Databases

NULL as a special marker in SQL or a relational database stands in place of a value that is missing, or in a join means "no corresponding row." The operators IS NULL and IS NOT NULL are required for comparisons to a literal null: other comparisons between NULL and any value evaluate to "unknown."

For more information, see Null (SQL).

ASCII

Null or NUL is the name given to the character with ASCII code zero (0) - i.e. hex 00. In some languages, notably C, NUL is used to mark the end of a character string.

For more information, see Null character.

16208 questions
8
votes
3 answers

Clearing a private collection or setting it to null?

I have a mutable class which has a private List field inside. In the Reset() method of my class, should I clear the list using its Clear() method or just assign its field a new list? Note that the list is not public and is only used by the class…
Şafak Gür
  • 7,045
  • 5
  • 59
  • 96
8
votes
8 answers

Is there an option to make Entity Framework revert empty strings to null?

I am using an ADO.NET Entity-Framework ObjectContext to access my data store. I want the if values are set with empty strings, they should automatically become null.
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
8
votes
2 answers

Finding all Nullable Columns in SQL 2000 Database

How to find out column with NULL values allowed in the insert in whole database ?
KuldipMCA
  • 3,079
  • 7
  • 28
  • 48
8
votes
2 answers

Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity; java.lang.NullPointerException

Im creating Triggers and Action Application for my Final Year Project, I return a child Activity result to intermediate activity and ther add some data to that activity and send it again to main activity, I did for both Trigger sub module and…
Thamilan S
  • 1,045
  • 3
  • 18
  • 30
8
votes
2 answers

CASE or COALESCE performance in WHERE clause for MySQL

I'm wondering which is the better performance or best practice when dealing with multiple criteria in the WHERE clause and NULL values. WHERE u.id = COALESCE(user_id, u.id) AND su.custom_id = COALESCE(student_number,…
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
8
votes
2 answers

Java RegEx that matches anything BUT literal string 'NIL' or 'nil'

OK, guys. Here's a Java interview-type question that seems to have stumped some very smart people around here. They actually need this for production code, so it's more than just an interview puzzler. They need a regular expression, in Java, that…
Armchair Bronco
  • 2,367
  • 4
  • 31
  • 44
7
votes
3 answers

Mongo {$ne : null} not working as expected

When I issue the following query: db.users.find({"pic.status" : {$ne : null} }, {"pic" : 1}).toArray() I expect to receive all users whose pic.status is NOT null. However, the actual result looks something like this: { …
Jens Ljungblad
  • 566
  • 1
  • 5
  • 11
7
votes
1 answer

Checking if a field allows null values in Django

I'm writing generic functions (using hasattr, setattr, getattr ...), in order to manage and update field values for a given field field_name of a certain model? Is there a way to check if the field my_model.field_name allows null values?
dolma33
  • 4,133
  • 6
  • 28
  • 48
7
votes
3 answers

Insert NULL instead of empty string with PDO

I have a table which has some nullable fields and when the user enters nothing into the HTML form field, I want to insert NULL into that field, not an empty string (this is important as some of my SELECTs on these tables later use conditions such as…
Alpaus
  • 646
  • 1
  • 7
  • 21
7
votes
3 answers

ALL or null with enums?

I've noticed I've been doing this inconsistently within the same project. In some places, I'll have an enum with an ALL option, and in others I'll have my enum as a nullable type with a null value indicating all (or no filter.) I noticed it when I…
Serinus
  • 195
  • 1
  • 9
7
votes
4 answers

Remove SelectedItem from TreeView

Is there a simple way to set a TreeView's SelectedItem to null or equivalent? Also, I need to do this in C# and not in XAML. Best regards, Gabriel
Gabriel
  • 464
  • 1
  • 5
  • 17
7
votes
4 answers

Count distinct and Null value is eliminated by an aggregate

I'm using SQL Server 2005. With the query below (simplified from my real query): select a,count(distinct b),sum(a) from (select 1 a,1 b union all select 2,2 union all select 2,null union all select 3,3 union all select 3,null union all select…
Simon D
  • 4,150
  • 5
  • 39
  • 47
7
votes
2 answers

Null stream, do I have to include ostream?

I am writing a logger. If disabled, this is the code which defines the LOG macro: #ifdef NO_LOG #include struct nullstream : std::ostream { nullstream() : std::ios(0), std::ostream(0) {} }; static nullstream logstream; #define LOG…
Pietro M
  • 1,905
  • 3
  • 20
  • 24
7
votes
4 answers

Why NULL values are mapped as 0 in Fact tables?

What is the reason that in measure fields in fact tables (dimensionally modeled data warehouses) NULL values are usually mapped as 0?
jrara
  • 16,239
  • 33
  • 89
  • 120
7
votes
2 answers

Lua: Is there a way to concatenate "nil" values?

I have the following function in Lua: function iffunc(k,str,str1) if k ~= 0 then return str .. k .. (str1 or "") end end This function allows me to check if value k is populated or not. I'm actually using it to determine if I want to…
Josh
  • 3,225
  • 7
  • 30
  • 44