Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Define Field(#A) Type(*DEC) Length(9) Decimals(0) Input_Atr(ASQN) Default(*SQLNULL) 
Define Field(#B) Type(*DEC) Length(9) Decimals(0) Input_Atr(ASQN) Default(*SQLNULL)
Define Field(#C) Type(*DEC) Length(9) Decimals(0) Default(*NULL)


Also See

 ASQN (Allow SQL Nulls) attribute

Specifying Conditions and Expressions in the Technical Reference Guide.

Anchor
Assignment
Assignment
Assignment

Info
If you wish to ensure that SQL Null fields are handled via ANSI rules for assignment, enable the *STRICT_NULL_ASSIGN function option. This option causes a fatal error to occur at execution time if the source field is SQL Null and the target field does not have the ASQN attribute.

...


You can also use the .AsValue intrinsic method to treat an SQL Null field as a different value. This is useful for mathematics and concatenation, where SQL Null or *NULL are not appropriate values. In the following example, we now get the result of 5 in #C if #B is SQL Null. However, if #B was 3, #C would be set to 15 because #B.AsValue only affects #B when it is SQL Null.

Code Block
#C := #B.AsValue( 1 ) * 5


Also See

*SQLNULL Keyword
Intrinsic Property .IsSqlNull
Intrinsic Method .AsValue

...

It is only when the result of the expression is assigned into the result field that a difference in behaviour behavior can occur. If the result of an expression is SQL Null, behaviour depends on whether the result field allows SQL Null and also on the function option *STRICT_NULL_ASSIGN. Refer to Assignment for details.

If you wish to change the value of SQL Null fields to something more appropriate, use Intrinsic Method .AsValue. For example, the result of expression '#B.AsValue(1) + 1' is 2 when #B is SQL Null (and 5 when #B is 4).

...