4. Understanding the Elements of SQL Statements : SQL Operations : Assignment Operations : Character String Assignments
 
Share this page                  
Character String Assignments
All character types are comparable with one another and with integer, decimal, and float types. Any character string can be assigned to any column or variable of character data type. A character string can also be assigned to a column or variable of integer, decimal, or float type, as long as the content of the string is a valid numeric value. The result of the assignment depends on the types of the assignment string and the receiving column or variable.
Assigned String
Receiving Column or Variable
Description
Fixed-length (c or char)
Fixed-length
Note:  The assigned string is truncated or padded with spaces if the receiving column or variable is not the same length as the fixed length string. If the assigned string is truncated to fit into a host variable, a warning condition is indicated in SQLWARN. For a discussion of the SQLWARN indicators, see SQL Communications Area (SQLCA) (see SQL Communications Area (SQLCA)).
Fixed-length
Variable-length (varchar, long varchar, or text)
The trailing spaces are trimmed. If the receiving column or variable is shorter than the fixed length string, the fixed length string is truncated from the right side. If the assignment was to a variable, a warning condition is indicated in SQLWARN. For a discussion of the SQLWARN indicators, see SQL Communications Area (SQLCA) (see SQL Communications Area (SQLCA)).
Note:  If a long varchar value over is assigned to another character data type, the result is truncated at the maximum row size configured but not exceeding 32,000 (16,000 in a UTF8 instance).
Variable-length (varchar, long varchar, or text)
Fixed-length
The assigned string is truncated or padded with spaces if the receiving column or variable is not the same length as the variable length string.
If a long varchar value over is assigned to another character data type, the result is truncated at the maximum row size configured but not exceeding 32,000 (16,000 in a UTF8 instance).
Variable-length
Variable-length
The variable length string is truncated if the receiving column or variable is not long enough.