null

T-SQL Stored Procedure NULL input values cause select statement to fail

Below is a stored procedure to check if there is a duplicate entry in the database based upon checking all the fields individually (don't ask why I should do this, it just has to be this way). It sounds perfectly straightforward but the SP fails. The problem is that some parameters passed into the SP may have a null value and therefore...

LINQ - Update null integer data field

I have got a field with data type int? price and allow null, when I set book.price = null; and update, it is not saved and does not throw any exceptions, when I change value # null, it is ok. I want set it null, plz help. ...

how to set pointer to a memory to NULL using memset?

Hi, I have a structure typedef struct my_s { int x; ... } my_T; my_t * p_my_t; I want to set the address of p_my_t to NULL, tried: memset (&p_my_t, 0, sizeof(my_t*)) This does not look right, what is the correct way of doing this? appreciate it... Amendment to question - asking a radically more complex question: Thank...

How is null represented in .NET

I was having a conversation with a co-worker and the subject of null came up. He was telling me that in .NET behind the scenes it is just a really small number. I always thought that the object just didn't have a pointer to any memory on the heap but i wasn't sure either way. So i'm hoping the community can clear it up for us ;P ...

SQLite3: Insert BLOB with NULL characters in C++

Hi everyone, I'm working on the development of a C++ API which uses custom-designed plugins to interface with different database engines using their APIs and specific SQL syntax. Currently, I'm attempting to find a way of inserting BLOBs, but since NULL is the terminating character in C/C++, the BLOB becomes truncated when construct...

NULL vs Empty when dealing with user input

Yes, another NULL vs empty string question. I agree with the idea that NULL means not set, while empty string means "a value that is empty". Here's my problem: If the default value for a column is NULL, how do I allow the user to enter that NULL. Let's say a new user is created on a system. There is a first and last name field; last na...

How to show if a method may return null

After posting this question and reading that one I realized that it is very important to know if a method is supposed to return null, or if this is considered an error condition and an exceptions should be thrown. There also is a nice discussion when to return ‘null’ or throw exception . I'm writing a method and I already know if I want...

C# Can I nullify an object from another class

I have an object that is generated in one class public class CreatingClass { public T CreateObject<T>(Dictionary<string, object> parameters) where T : IMyInterface, new() { .... } public void DestroyObject(IMyInterface objectToDestroy) { .... } } I call this function from a client class, then a...

Checking for null, which is better? "null ==" or "==null"

Dupe: http://stackoverflow.com/questions/302701/null-difference A lifetime ago I came across an article that explained that the following were not equal (in c#): if (o == null) {} if (null == o) {} The article explained that the latter was preferred because it resulted in a more accurate test. I've been coding like that ever since. N...

Grails Domain Class without ID field or with partially NULL composite field

Per an answer to a previous question (answer here: http://stackoverflow.com/questions/425294/sql-database-views-in-grails#427691), I have tried to use a domain class to represent a view in my database. This works wonderfully in most cases, however: I have a view with no single unique key. Let's say the underlying tables look like this: ...

Unexpected proxy objects in Nhibernate with composite ID's

I have a data structure which uses composite ids (Which I dont wish to change to single) Everything loads fine except for many-to-one joins which if the join is empty, instead of mapping the property to null, maps it to an empty proxy object. I have written an ugly work around( see bleow). Any solutions to this? private Node _Parent; ...

MySQL foreign key to allow NULL?

Hi there, I'm piecing together an image website. The basic schema's pretty simple MySQL, but I'm having some trouble trying to represent possible admin flags associated with an image ("inappropriate", "copyrighted", etc.). My current notion is as follows: tblImages ( imageID INT UNSIGNED NOT NULL AUTO_INCREMENT, ... ); tblImag...

Does assigning objects to null in Java impact garbage collection?

Does assigning an unused object to null in Java improve the garbage collection process in any measurable way? My experience with Java (and C#) has taught me that is often counter intuitive to try and outsmart the virtual machine or JIT, but I've seen co-workers use this method and I am curious if this is a good practice to pick up or on...

SQL nvl equivalent - without if/case statements & isnull & coalesce

Are there any nvl() equivalent functions in SQL? Or something close enough to be used in the same way in certain scenarios? UPDATE: no if statementsno case statementsno isnullno coalesce select nvl (purge_date,"SODIUFOSDIUFSDOIFUDSF") from id_rec where id=36581; (expression) SODIUFOSDIUFSDOIFUDSF 1 row(s) retrieved. select isnul...

C# enumeration property null vs. 0

I'm using IIS/asmx to support a Flash client. Some of my service layer data transfer objects have properties that are enumeration values. There are cases where these properties should be null. When an object with a null value for such an enumeration property is rendered to soap, I receive this error: System.InvalidOperationExceptio...

Updating Nulls

Hello, I am trying to generate a data layer template. When I do my Selects, Updates, and Inserts, the idea is to have the template work with all the columns because I don't know which one's contain values or not. The problem is that I may have an update statemtent like cmd.Parameters.AddWithValue("@Field", this.Field); and if that value...

Is NULL always false?

Is it safe to assume that NULL always translates to false in C? void *somePtr = NULL; if (!somePtr) { /* This will always be executed? */ } Or should an explicit check against the value of NULL be made? ...

Enterprise Library Validation Block - Validate nullable properties?

I am trying to come up with a validation for a nullable property, like int? Example [RangeValidator(0, RangeBoundaryType.Inclusive, 1, RangeBoundaryType.Inclusive)] int? Age { get; set; } However if I set Age to null validation fails because it doesn't fall in the range, I know I need an [ValidatorComposition(CompositionType....

C# Overriding Equals using "as" and specialized Method for Correctness, Flexibility and Performance

I wondered about the best way to implement a correct, flexible and fast Equals in C#, that can be used for practically any class and situation. I figured that a specialized Equals (taking an object of the actual class as parameter) is needed for performance. To avoid code duplication, the general Equals ought to call the specialized Equa...

Why is there a `null` value in JavaScript?

In JavaScript, there are two values which basically say 'I don't exist' - undefined and null. A property to which a programmer has not assigned anything will be undefined, but in order for a property to become null, null must be explicitly assigned to it. I once thought that there was a need for null because undefined is a primitive va...