The basic rule for date, time, and timestamp assignments is that a value may only be assigned to a column with a matching data type, or to a fixed or varying length character string variable or column.
If the assignment of a date or time value is made to a character string variable or column, conversion to a string representation is automatic. Leading zeros are not omitted from any part of the date, time or timestamp. The required length of the target varies depending on the format of the string representation. If the length of the target is greater than required, it is padded on the right with blanks. If the length of the target is less than required, the result depends on the type of date or time value involved, as well as on the type of target. If the target is a column, truncation is not allowed. The length must therefore be 10 for a date, 8 for a time, and 26 for a timestamp.
If the target is a host variable, the following rules apply:
If the string or column length is less than ten bytes, an error occurs.
If the USA format is used (see Character String Literals for additional format information), the length of your host variable or string column must not be less than 8. Otherwise, its length must not be less than 5.
If ISO or JIS formats are used, and if the length of the host variable is less than 8, the seconds part of the time is omitted from your result and assigned to your indicator variable. The SQLCA-WARNING(2) field of the SQLCA (SQLWARN1 in the DB2 format) is set to alert you to the omission.
If the string or column length is less than 19 bytes, an error occurs. If the length is less than 26 bytes but greater than or equal to 19 bytes, trailing digits of the microseconds part of the value are omitted.
|
Copyright © 2014 CA.
All rights reserved.
|
|