4. Elements of OpenSQL Statements : Operations : Assignment Operations : Character String Assignment
 
Share this page                  
Character String Assignment
The character and varchar character types are compatible. Any character string can be assigned to any column or variable of character data type. (If an assignment results in truncation, OpenSQL returns a warning.) The result of the assignment depends on the types of the assignment string and the receiving column or variable:
If a character string is assigned to a varchar column or variable, trailing blanks are trimmed from the character string before it is assigned.
If the length of the receiving string is shorter than the fixed length string, OpenSQL truncates the fixed length string (from the right end) and, if the assignment was to a variable, a warning condition is indicated. For a discussion of the SQLWARN indicators, see The SQL Communications Area (SQLCA) in the chapter “OpenSQL Features.”
If a string is assigned to a column or variable that is shorter than the fixedlength string, OpenSQL truncates the fixedlength string from the right end. If a fixedlength string is assigned to a fixedlength column or variable that is longer than the fixedlength string, OpenSQL pads it with blanks. If the assignment is to a variable and the string is truncated, a warning is indicated in the SQLCA.