C to SQL conversion for timestamp data

You can convert the timestamp C data type, SQL_C_TYPE_TIMESTAMP, to an SQL data type.

The following table shows information about converting timestamp C data to SQL data.

Table 1. Conversion of timestamp C data to SQL data
fSqlType Test SQLSTATE
Start of change
SQL_CHAR
SQL_VARCHAR
End of change
Start of changeColumn length >= Display sizeEnd of change Start of change000001End of change
19 <= Column length < Display size 01004
Column length < 19 22003
Fractional seconds field length > 12 (display size > 32) 22008
SQL_TYPE_DATE Data value is a valid date, and time fields are 0 000001
Data value is a valid date, and time fields are not 02 01004
Data value is not a valid date 22008
SQL_TYPE_TIME Data value is a valid time. Fractional seconds fields are zero. 000001
Data value is a valid time. Fractional seconds fields are not zero. 01004
Data value is not a valid time. 22008
Start of changeSQL_TYPE_TIMESTAMPEnd of change Start of changeData value is a valid timestampEnd of change Start of change000001End of change
Start of changeData value is not a valid timestampEnd of change Start of change22008End of change
Start of changePrecision specified by TIMESTAMP(p) < fractional seconds field length <= 124End of change Start of change000001End of change
Notes:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.
  2. The time portion of the timestamp is deleted.
  3. The date portion of the timestamp is deleted.
  4. Fractional seconds of the timestamp are truncated.
  5. The time zone component of TIMESTAMP is set based on either CLIENTTIMEZONE, SESSIONTIMEZONE, or the current system time zone of the machine the application is running.