Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is a null in sql equivalent to a null in C++.I need to write this app where I have to check frequently to know if a field in a record is null.I just needed to know if the two are equivalent so I can determine how best to check for nullity.
Posted

They are NOT equivalent. I guess the C# Nullable types[^] are more closer to SQL corrispondent types.
 
Share this answer
 
Hi,

NULL in SQL and C++ are not equivalent. In SQL, NULL indicates that the value is unknown (data value does not exist in the database) and is different from an empty or zero value. Here is more information (SQL Server):
Null Values[^]
 
Share this answer
 
Comments
Gbenbam 4-Feb-14 7:33am    
So how on earth does one test for a null in a C++ program that queries database using sql?
markkuk 4-Feb-14 9:51am    
See the documentation of your database interface library. It should provide a function to test for SQL NULL values, e.g. MySQL C++ connector has ResultSet::IsNull()
Andrius Leonavicius 4-Feb-14 16:16pm    
markkuk is right. Unfortunately, there is no general answer how to test for a NULL and it depends on particular C++ library for accessing SQL database. Good luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900