Questions tagged [notnull]

This tag refers to an object or type that is not null (none).

Use this tag for questions related to not-null types or objects (i.e. detecting them, handling them, etc.).

295 questions
320
votes
10 answers

MySQL SELECT only not null values

Is it possible to do a select statement that takes only NOT NULL values? Right now I am using this: SELECT * FROM table And then I have to filter out the null values with a php loop. Is there a way to do: SELECT * (that are NOT NULL) FROM…
bryan sammon
  • 7,161
  • 15
  • 38
  • 48
213
votes
17 answers

How do I check if a SQL Server text column is empty?

I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response: The data types text and varchar are…
atoumey
  • 2,536
  • 2
  • 20
  • 16
178
votes
8 answers

insert a NOT NULL column to an existing table

I have tried: ALTER TABLE MY_TABLE ADD STAGE INT NOT NULL; But it gives this error message: ALTER TABLE only allows columns to be added that can contain nulls or have a DEFAULT definition specified
ANP
  • 15,287
  • 22
  • 58
  • 79
150
votes
1 answer

Why does the C# compiler translate this != comparison as if it were a > comparison?

I have by pure chance discovered that the C# compiler turns this method: static bool IsNotNull(object obj) { return obj != null; } …into this CIL: .method private hidebysig static bool IsNotNull(object obj) cil managed { ldarg.0 // obj …
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
148
votes
5 answers

Ruby on Rails: How do I add a not null constraint to an existing column using a migration?

In my Rails (3.2) app, I have a bunch of tables in my database but I forgot to add a few not null constraints. How can I write a migration which adds not null to an existing column?
David Robertson
  • 1,809
  • 3
  • 12
  • 12
101
votes
6 answers

How to drop all NOT NULL constraints from a PostgreSQL table in one go

Is it possible to drop all NOT NULL constraints from a table in one go? I have a big table with a lot of NOT NULL constraints and I'm searching for a solution that is faster than dropping them separately.
Stefan
  • 1,383
  • 2
  • 15
  • 25
60
votes
4 answers

Not annotated method overrides method annotated with @NotNull

I'm implementing a custom data structure that gives me some properties of sets and other properties of lists. For most of the implemented methods though, I get this weird warning in IntelliJ IDEA on Java 7: Not annotated method overrides method…
BrDaHa
  • 5,138
  • 5
  • 32
  • 47
48
votes
6 answers

How to ignore null values using springframework BeanUtils copyProperties?

I would like to know how to copy the properties from an Object Source to an Object Dest ignoring null values​​ using Spring Framework. I actually use Apache beanutils, with this code beanUtils.setExcludeNulls(true); …
Fingolricks
  • 1,196
  • 2
  • 14
  • 30
41
votes
4 answers

Hibernate @NotEmpty annotation equivalent in Javax.package or alternative

Is there a way to implement @NotEmpty hibernate validation without writing custom validation? javax.validation package does not contain this annotation. Only @NotNull. But it does not validate for Non-null but empty values. So I would like to see an…
Kevin Rave
  • 13,876
  • 35
  • 109
  • 173
34
votes
4 answers

Sql Conditional Not Null Constraint

I am curious to know is it possible to create a conditional not null constraint in sql? In otherwords is it possible to create a constraint such that a column B can be null as long column A contains lets say 'NEW' but if the contents of column A…
Heinrich
  • 2,144
  • 3
  • 23
  • 39
32
votes
5 answers

Alter column default value

I know you can change the default value of an existing column like this: ALTER TABLE Employee ADD CONSTRAINT DF_SomeName DEFAULT N'SANDNES' FOR CityBorn; But according to this my query supposed to work: ALTER TABLE MyTable ALTER COLUMN CreateDate…
SZT
  • 1,771
  • 4
  • 26
  • 53
28
votes
2 answers

MySQL - How Do I Count Nulls and Not Nulls?

I have a simple table of installs: prod_code email install_slot If the install_slot is NULL, then it's an available install slot. Not null -- then, used slot. I need to return a result of total installs for a given product and email, as well as a…
Volomike
  • 23,743
  • 21
  • 113
  • 209
28
votes
3 answers

Alter column set not null fails

Consider the following table with approximately 10M rows CREATE TABLE user ( id bigint NOT NULL, ... CONSTRAINT user_pk PRIMARY KEY (id) ) WITH ( OIDS=FALSE ) Then i applied the following alter ALTER TABLE USER ADD COLUMN BUSINESS_ID …
dimcookies
  • 1,930
  • 7
  • 31
  • 37
25
votes
1 answer

Not annotated parameter overrides @??? parameter

While overriding code: @Override public void open(ExecutionContext executionContext) { super.open(executionContext); from: org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader I received an IntelliJ…
DerBenniAusA
  • 727
  • 1
  • 7
  • 13
24
votes
2 answers

Check a record IS NOT NULL in plsql

I have a function which would return a record with type my_table%ROWTYPE, and in the caller, I could check if the returned record is null, but PL/SQL complains the if-statement that PLS-00306: wrong number or types of arguments in call to 'IS NOT…
Sapience
  • 1,545
  • 3
  • 14
  • 24
1
2 3
19 20