How to correctly handle NULL in the database

zhaozj2021-02-16  77

For beginners, there is a bit of trouble in processing the NULL data in the database. In this article article, we will talk about null, you will know how to know that a value is null, which functions can or not Processing NULL First, we must know that in VBScript, Variant is the only data type, which may feel a bit not used to those program developers who are familiar with other languages. The advantage of using Variant is that it is quite flexible because Variant can store any data type, such as an integer, string, datetime, and even objects and arrays. However, elasticity is a cost, because the specified Variant may have more specific subtypes in the Variant data type (Subty): EMPTY and NULL, in fact The type may not be appropriate because they don't store some values. When a variable is used as EMPTY or NULL, their value is EMPTY or NULL EMPTY a variable after being declared, but before it is specified. This variable's information subtype is EMPTY. In other words, EMPTY is equivalent to "has not been initialized", let's take a look at the example DIM VARTEST RESPONSE.WRITE TYPENAME (VARTEST) The execution result should be Empty, so Empty can say Is the initial data sub-type and initial value of a variable, EMPTY only represents a variable state, try the following example DIM VARTEST RESPONSE.WRITE CLNG (VARTEST) RESPONSE.WRITE CSTR (VARTEST) The program will be displayed 0, Because EMPTY is expressed as an integer, it is 0, and the result of the second line will not be displayed, because Empty is EMPTY when it is represented as a string, or can be said to be a zero string when a variable is specified After a value, it is no longer EMPTY, which will be other subtypes, depending on the type of information. Of course, you can also use the Empty this variable back to the EMPTY subtype Vartest = Empty In two ways, you can judge whether a variable is EMPTY IF VARTEST = EMPTY THEN RESE.WRITE "The Variable Is Empty." End if ISempty (Vartest) Then Response.write "The variable is empty." End if null null This subscript type and EMPTY is very similar, but different points are that EMPTY represents a variable has not been initialized, that is, the value has not been given any value, and a variable is NULL only after you specify it to null.

转载请注明原文地址:https://www.9cbs.com/read-16219.html

New Post(0)