Field Type Conversions

LANSA Technical

Field Type Conversions

Following are the basic field type groupings used in LANSA:

Character/String

Store alpha data that is either SBCS, mixed SBCS and DBCS, or DBCS-only. Includes types Alpha, String, Char, and CLOB.

Unicode Character/String

Store alpha data in Unicode. (Character/String are stored in the native codepage.) Multiple languages can be handled without data loss. Includes types NChar and NVarChar.

Numeric

Store numeric data in a variety of formats. Includes types Signed, Packed, Integer, and Float.

Date/Time

Store date and time data. Includes types Date, Time, DateTime.

Binary

Store binary data. (This data is not subject to codepage conversion.) Includes types Binary, VarBinary, BLOB.

LOB

Store very large character or binary data. Includes types CLOB, BLOB.

Boolean

Store a True or False value.

 

The following table summarizes field conversions between groups. Yes indicates that conversion between the field type groups is allowed. It does not indicate that conversion will always be successful. For example, you cannot convert DBCS data to SBCS data, or a value like "Hello world" to a Numeric.

General Conversion Rules

         From:
To:

Character

Unicode Character

Numeric

Date/Time

Binary

LOB 4

Boolean

Character

Yes

Yes 5

Yes 1

Yes 1

Yes

Yes

Yes

Unicode Character

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Numeric

Yes

Yes

Yes

Yes 2

No

No

Yes

Date/Time

Yes

Yes

Yes 2

Yes 3

No

No

No

Binary

Yes

Yes

No

No

Yes

No

No

LOB 4

Yes

Yes 5

No

No

Yes

Yes

No

Boolean

Yes

Yes

Yes

No

No

No

Yes

 

 

Table notes:

1.  CLOBs are treated as file pointers, so do not support conversion to a Numeric or Date/Time field type.

2.  No support for conversion

  • between Integer or Float and the Date/Time field types
  • of a numeric type directly to a DateTime, as there is no way to determine if the type should be setting the Date or Time portion of the DateTime.

3.  DateTime -> Date and DateTime -> Time are obvious.

  • The default Date is 1900-01-01 and the default time is midnight (00:00:00). Therefore:
  • Date -> DateTime sets the time part to midnight
  • Time -> DateTime sets the date part to 1900-01-01
  • Date -> Time always results in midnight
  • Time -> Date always results in 1900-01-01

4.  The "value" for a LOB is a filename. Thus, when converting it is the filenames that are being copied, not the data. If an invalid filename is copied to a LOB, an error will occur at some stage.

5.  When converting a Unicode string to a native string, the intrinsic .AsNativeString may need to be used.

 

Ý 1.1.1 Field Type Considerations