1.1.4 NVarChar
NVarChar is a variable-length character field, with a maximum length between 1 and 65,535. (This is the number of characters, not the byte length.)
NVarChars store alpha data of any codepage. For example, in a list, an NVarChar field may have Japanese in one row, and French in another row.
NVarChars are classified as unicode strings.
An NVarChar retains any trailing blanks, they are significant. When concatenating an NVarChar with spaces on the end, those spaces are retained. But the space is NOT SIGNIFICANT for comparisons.
Please review the general 1.1.1 Field Type Considerations.
Field Definition Rules
Rules for defining an NVarChar field in the repository are:
Length |
NVarChars may be 1 to 65,535 in length. NVarChars have no decimals. |
Valid Keyboard Shift |
Blanks. |
Allowed Attributes |
AB, ASQN, CS, FE, LC, ND, RA, RB, RL, RLTB, SREV. |
Edit Mask |
NVarChars may be used for lookup predermined joined fields. |
Default |
*NULL |
Usage Rules
Partition Type |
|
Files |
NVarChars may only be used in RDMLX Files. NVarChars may be used as real or key fields. If used as keys, length must be no more than 2000 characters. |
Logical Views |
NVarChars may be used as key fields. If used as keys, length must be less than 2000 characters. |
Virtual Fields |
NVarChars may be used with Code Fragment Virtual Fields. |
Predetermined Join Fields |
NVarChars may be used for lookup predermined joined fields. |
RDML Commands |
DEF_FOOT, DEF_BREAK, and DEF_LINE only support printing of RDML fields. Therefore, NVarChar fields need to be converted to Alpha to be used in reports. |
Built-In Functions |
When used in Built-In Functions, NVarChars are valid for arguments of type 'A'. |
Special Values |
*NULL, *NAVAIL, |
Conversion |
Refer to Field Type Conversions. |
Usage Notes
- Working fields may be defined as TYPE(*NVARCHAR).
- A NVarChar of zero length has a space added to it before inserting or updating the database via Sql. This is in order to obtain consistent behaviour between our databases. Without a space, Oracle interprets the data as being SQL Null, which is not strictly true and is not how the other databases behave.
So, be aware that your application cannot make a distinction between an empty NVarChar and a NVarChar with 1 blank. Also, concatenations of a zero length NVarChar before inserting to the database and after reading may differ by the extra space. Behaviour can be made consistent by truncating trailing spaces before using NVarChars in an expression. Note that when comparing an empty NVarChar in RDML to an NVarChar with 1 space read from the database they will compare equal because trailing spaces are not significant in comparisons - they are only significant in expressions, like concatenation.
Platform Considerations
- Refer to Platform Considerations in 1.1.1 Field Type Considerations.
Tips & Techniques
- If there is no need to support multiple languages at execution time, use an Alpha field or a String field.
Also See