Created On:  16 October 2012

Problem:

Oracle DATE columns actually contain a timestamp value consisting of the date part and a time part.  How can I retrieve the entire timestamp value into my program?

Resolution:

The OpenESQL precompiler looks at the size of the host variable being used and will retrieve the appropriate value depending on this size.

So if you have a SELECT statement that looks like:

     EXEC SQL 
          SELECT
              A.HireDate
          INTO
             :Employee-HireDate
          FROM Employee A
              WHERE ( A.EmployeeID = :Employee-EmployeeID )
     END-EXEC

If Employee-HireDate...

01  Employee-HireDate      pic x(10).
or
01 Employee-HireDate SQL TYPE DATE.

The value returned will be just the date part, e.g. 1978-12-21

01 Employee-HireDate       pic x(29).
or
01 Employee-HireDate SQL TYPE TIMESTAMP.

The value returned will be date and time parts, e.g. 1978-12-21 02:15:10.0000000