Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How user defined data type treat the null values

Former Member
0 Likes
867
  • SAP Managed Tags

According to the documentation. using sp_addtype, we specifying null type The null type determines how the user-defined datatype treats nulls. You can create a user-defined datatype with a null type of “null”, “NULL”, “nonull”, “NONULL”, “not null”, or “NOT NULL”.

However, It seems NONULL or NOT NULL provided in the type definition will not prevent the type from accepting the null value. Any idea?

My test is like the following. There is no error raised when assign, the new type variable can have NULL value assigned to it.

Thank you very much.

ASE 16

1> sp_addtype nm , "varchar(20)", "NONULL"

2> go Type added.

(return status = 0)

1> declare @ss nm

2> select @ss = null

3> go

(1 row affected)

1> declare @ss nm

2> select @ss = null

3> select isnull(@ss,"NULLVAL")

4> go

(1 row affected)

----------------------------------------

NULLVAL (1 row affected)

According to the documentation. using sp_addtype, we specifying null type The null type determines how the user-defined datatype treats nulls. You can create a user-defined datatype with a null type of “null”, “NULL”, “nonull”, “NONULL”, “not null”, or “NOT NULL”.

However, It seems NONULL or NOT NULL provided in the type definition will not prevent the type from accepting the null value. Any idea?

My test is like the following. There is no error raised when assign, the new type variable can have NULL value assigned to it.

Thank you very much.

ASE 16

1> sp_addtype nm , "varchar(20)", "NONULL"

2> go Type added.

(return status = 0)

1> declare @ss nm

2> select @ss = null

3> go

(1 row affected)

1> declare @ss nm

2> select @ss = null

3> select isnull(@ss,"NULLVAL")

4> go

(1 row affected)

----------------------------------------

NULLVAL (1 row affected)

0 REPLIES 0