Previous Topic Next topic Print topic


TIMESTAMP

Data Format

If a COBOL output host variable is defined for an SQL timestamp value, the date and time are specified in the following format:
					yyyy-mm-dd hh:mm:ss[.f[f[...]]]
where the number of fractional digits is driver-defined. For example:
1994-05-24 12:34:00.000

Host Variable Formats

OpenESQL and DB2 ECM
01 timestamp1         PIC X(29).
01 timestamp2         SQL TYPE IS TIMESTAMP.

The timestamp2 format uses the TIMESTAMP SQL TYPE.

OpenESQL
01 timestamp3         SQL TYPE IS TIMESTAMP-RECORD.
  • When using the timestamp1 format:
    • OpenESQL requires that you compile applications with the DETECTDATE SQL directive.
    • To move time specifications into the host variable:
      • To specify a time only, move the time into the host variable in the form:
        {t 'hh:mm:ss'} 
      • To specify a time and a date, move them together into the host variable in the form:
        {ts 'yyyy-mm-dd
        													hh:mm:ss[.f[f[...]]]'
        For example:
        $set sql(dbman=odbc, detectdate) 
         01 timestamp1 pic x(26).
          . . . 
             move "{ts'1965-11-02 12:08:30'}" to timestamp1 
             exec sql 
                 insert into emp (TransDate) values (:timestamp1) 
             end-exec 
  • When using the timestamp2 format, you can just move the date/time literal without the special characters. For example:
    01 timestamp2 SQL TYPE IS TIMESTAMP.
      . . . 
         move "1965-11-02 08:12:56"  to timestamp2
         exec sql 
             insert into emp (TransDate) values (:timestamp2) 
         end-exec
  • The timestamp3 format uses the TIMESTAMP SQL TYPE.
OpenESQL .NET Managed Runtime
In addition to the definitions valid for all databases and those valid for OpenESQL, the following definition is also valid for the OpenESQL .NET Managed Runtime:
01 timestamp4         type System.DateTime.
DB2 ECM

The TIMESTAMP data type has a maximum length of 26 characters.

Previous Topic Next topic Print topic